[TYPO3-mvc] @lazy in model does not bring the expected results... why?

Franz Koch typo3.RemoveForMessage at elements-net.de
Thu Jul 14 17:05:22 CEST 2011


Hey,

> 	/**
> 	 * @param Tx_Mrad_Domain_Model_Category $category
> 	 * @return void
> 	 */
> 	public function setCategory(Tx_Mrad_Domain_Model_Category $category) {
> 		if ($this->category instanceof Tx_Extbase_Persistence_LazyLoadingProxy) {
> 			$this->category->_loadRealInstance();
> 		}
> 		return $this->category;			
> 	}

what's that? Looks like you mixed the setter and getter.
a) you don't ever assign $category to $this->category
b) what's that stuff with the LazyLoadingProxy? By doing this it's like 
you wouldn't enable lazy loading at all. Also you're using a internal 
method not meant to be directly used by devs without knowing what they 
do and how it behaves.

So simply strip this method down to this and test again:

public function setCategory(Tx... $category) {
   $this->category = $category;
}

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list