[TYPO3-mvc] LazyLoadinProxy and TypeHinting causes fatal error

Stephan Schuler Stephan.Schuler at netlogix.de
Fri Jan 17 11:23:20 CET 2014


Hey there.


I think "that's what it is" is exactly the right answer. Working around that is kind of hard.

When you look at flow, there is a unique LazyLoadingProxy class for each individual domain object class. Like a FrontendUserLazyLoadingProxy for the FrontendUser, where the FrontendUserLazyLoadingProxy extends the FrontendUser. This way the LazyLoadingProxy *is* a FrontendUser and can be used wherever a FrontendUser is expected.


This has two drawbacks.

The first: It will increase the number of classes, since you need an additional class for every domain object. But that shouldn't be the point because that doesn't increase any relevant performance parameter in a significant way. So just the need for additional classes isn't an issue for me.

The second thing is the more important one: It requires dynamic class building. Flow calls it "Proxy Class Building", and it's a very central part of Flow. I doubt such a thing will make it into TYPO3.CMS any time soon.

The only way to go: Just skip the PHP type hints and stick to annotations.
Annotations will make your IDE aware of what is expected, and TYPO3 will use it when it comes to property mapping. But the executed PHP code goes without those and therefor they cannot break anything.


If course this problem isn't only related to a repository call, or anything else where you have complete control about argument passing. Think about some ViewHelpers. MySepcialViewHelper::render can be defined to take a FrontendUser object. When you deal with LazyLoadingProxy objects of FrontendUsers, pass them to Fluid and then call MySpecialViewHelper with this LazyLoadingProxy, this isn't going to work, too.


And that's the reason for my suggestion: Skip PHP type hints and just use "@var" annotations.


Regards,




Stephan Schuler
Web-Entwickler

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Website: media.netlogix.de



--
netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Internet: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Philipp
Gesendet: Freitag, 17. Januar 2014 10:38
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: Re: [TYPO3-mvc] LazyLoadinProxy and TypeHinting causes fatal error

$objects = $this->objectRepository->findDemanded($demand);
$count = $objects->count();
if ($count>0) {
$processed = 0;
while ($processed < $count) {
$query = $objects->getQuery();
$query->setLimit(50);
if ($processed) $query->setOffset($processed); $objects = $query->execute()->toArray(); foreach ($objects as $object) { $this->addObjectToReturn($object);
$processed++;
}
$this->persistenceManager->clearState();
}
}

This way the memory consumption went down to ~10% parsing time is still _very_ high.
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


More information about the TYPO3-project-typo3v4mvc mailing list