[TYPO3-mvc] Using Repository outside a controller
Michiel Roos [netcreators]
michiel at netcreators.com
Sat Jul 24 12:00:05 CEST 2010
On 7/23/10 10:16 PM, Michiel Roos [netcreators] wrote:
> Have you gotten 'lazy loading' of related objects to work?
Ok, seems to be related to the same respectStoragePage issue.
I can work around it by defining a findBy function in the related item's
repository like so:
public function findByThing(Tx_NcgovVerseonris_Domain_Model_Thing
$agendapunt, $respectStoragePage = TRUE) {
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage((bool)$respectStoragePage);
return $query->matching($query->contains('things', $thing))
->setOrderings(array('datum' =>
Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING))
->execute();
}
Then I have to manually get related objects by doing:
$things = $this->thingRepository->findByUniqueId($itemRecord['uid']);
$blurbs = $this->blurbRepository->findByThing($things[0], FALSE);
That gives me the blurbs that are related to things[0]
It's painful but it's a workable solution for the extbase shipping with
4.4.0.
--
Met vriendelijke groet / Warm regards,
Michiel Roos
Chief Technical Officer
Netcreators: Open Source, Open Minds, Open People
More information about the TYPO3-project-typo3v4mvc
mailing list