[TYPO3-mvc] Possible bug: LazyObjectStorage->toArray should initialize the objectStorage first?

Thomas "Thasmo" Deinhamer thasmo at gmail.com
Sat May 29 00:43:37 CEST 2010


Am 29.05.2010 00:28, schrieb Franz Koch:

> I'm using a LazyObjectStorage as property of a model and had it
> converted to a plain array via $myLazyObjectStorage->toArray();. I do
> this, because I like to merge the results of various parent objects
> ($collection =
> array_merge($collection,$myObject->getMyLazyProperty()->toArray()).
> This used worked just fine before, but now it's returning an empty
> array, because the LazyObjectStorage is not initialized before. So
> question is, should this method take care of the initialization, or are
> we supposed to initialize the LazyObjectStorage via some other API calls
> (like ->valid() or ->rewind()) first (which feels a bit odd)? What do
> you guys thing about it?
>

Hello Franz,

I'm not sure if this is directly related to your problem, but inside the 
domain models it's always done like this for lazy loading:

public function getCategories() {
	if($this->categories instanceof Tx_Extbase_Persistence_LazyLoadingProxy) {
		$this->categories->_loadRealInstance();
	}
	
	return clone $this->categories;
}

Not sure if this helps you. But even if this is not related to your 
problem, it's similar - maybe it's also possible to get rid of this 
manual loading of the 'real' objects and let Extbase load it when they 
are accessed?!

Thomas


More information about the TYPO3-project-typo3v4mvc mailing list