[TYPO3-mvc] Repository doesn't work if called from different controller
Franz Koch
typo3.RemoveForMessage at elements-net.de
Thu Jan 20 23:38:56 CET 2011
Hey Raymund,
> At one point an action is called that should show all projects that
> were done for a given customer. But the call to the project repository
> returns no projects.
>
> Here's part of the code:
>
> /**
> * Renders a single customer
> *
> * @param Tx_UtekReferenzen_Domain_Model_Customer $customer The customer to be displayed
> * @return string The rendered HTML string
> */
> public function showAction(Tx_UtekReferenzen_Domain_Model_Customer $customer) {
> $projectRespository = t3lib_div::makeInstance('Tx_UtekReferenzen_Domain_Repository_ProjectRepository');
It's not related to your issue, but instead of using
t3lib_div::makeInstance you should use
$this->objectManager->get('ClassName') instead in future, because only
then you can make use of all the good new stuff like DependencyInjection
extbase is providing for you.
> $this->view->assign('customer', $customer);
> $this->view->assign('projects', $projectRespository->findAll());
> }
I think in the final version it should be
$projectRepository->findByCustomer($customer) in order to get only the
projects for this customer.
> public function findAll()
> {
> t3lib_div::devLog('Projects: findAll', 'utek_referenzen', 0);
> $query = $this->createQuery();
> $result = $query->execute();
> t3lib_div::devLog('result:' . $result->count(), 'utek_referenzen',0);
> return $result;
> }
>
> If called from ProjectController.listAction() the debug log says some
> projects found. If called by CustomerController.showAction() it says 0
> projects found.
>
> I have no idea why that happens. I have a background repository for
> services provide in the projects and that is used in
> ProjectController.listAction() and works just fine.
Have you checked if the storagePid applies correctly? If you're storing
the customers and the projects in different folders you have to define
both PIDs as storagePid (comma separated).
> Is there a way to output the SQL query to the debugLog? The used
> version is Typo3 v4.5beta4.
You would have to add a debugLog call yourself inside
Tx_Extbase_Persistence_Storage_Typo3DbBackend.
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list