[TYPO3-mvc] Passing LazyLoadingProxy to DomainService
Thomas "Thasmo" Deinhamer
thasmo at gmail.com
Mon Feb 14 12:38:25 CET 2011
Hello folks!
Normally when returning lazy loaded objects from within models
I don't load the real instance inside the getter method. I guess
for templates, Fluid is capable of loading the real instance of
lazy loaded objects.
But if I pass a returned lazy loading proxy object from a getter
to one of my domain services, it expects a concrete model object,
not a lazy loading proxy:
Method:
getPrice(Tx_HypeStore_Domain_Model_Product $product, $quantity = 1){}
Call:
$product = $category->getOneProduct(); // fictive method here, returns
lazy loading proxy object
$this->service->getPrice($product, 1);
Now the error is:
Argument 1 passed to
Tx_HypeStore_Domain_Service_ProductService::getPrice() must be an
instance of Tx_HypeStore_Domain_Model_Product, instance of
Tx_Extbase_Persistence_LazyLoadingProxy given...
Is the only proper solution to load the real instance inside the
getter method of the parent object or is there any better solution?
Thanks a lot,
Thomas
More information about the TYPO3-project-typo3v4mvc
mailing list