[TYPO3-mvc] LazyLoadinProxy and TypeHinting causes fatal error

Nicolas de Haen typo3 at ndh-websolutions.de
Fri Jan 17 00:05:52 CET 2014


Hi,

when a LazyLoadingProxy is passed to a method which has a TypeHint of 
the RealInstance class it will result in a fatal error.

LazyLoading proxies will be instantiated only when a method is called, 
so it seems that properties anootated as @lazy can not be passed to 
methods except _loadRealInstance is explicitly called before.

Simple example:

User has a property Team wich is annotated as @lazy

A method

findBySomethingByTeam(\VENDOR\Extension\Domain\Model\Team $team)

will cause a fatal error when called like this:

$team = $user->getTeam();
findBySomethingByTeam($team);

It seems that "lazy" properties need a getter like this:

public function getTeam() {
	if($this->team instanceof LazyLoadingProxy) {
		return $this->team->_loadRealInstance();
	}
	return $this->team;
}

Is that a known issue?

regards,
Nico



-- 
Nico de Haen
ndh websolutions

Webprogrammierung, OpenSource, Typo3



http://www.ndh-websolutions.de


More information about the TYPO3-project-typo3v4mvc mailing list