[TYPO3-mvc] LazyLoadinProxy and TypeHinting causes fatal error
Philipp
philippwrann at gmx.at
Fri Jan 17 08:42:29 CET 2014
Thats how it is.... in methods you expect a lazy property you have to respect the possibility of a LazyLoadingProxy
I would not place the realInstanceLoading in the getter, sometimes you just want to know if a lazy property is set or if the property is NULL...
but you could implement a method like load in your model
public function load() {return $this}
Then you could do something like
if ($user->getTeam()) doSomething($user->getTeam()->load())
OR
you could implement a method called hasTeam in your aggregate doing just
return ($this->team === NULL) ? FALSE : TRUE
and do your mechanism in the getTeam method...
I would simply do it like:
somefunction($team) {
if ($team instanceof LazyLoadingProxy) $team = $team->_loadRealInstance();
}
More information about the TYPO3-project-typo3v4mvc
mailing list