[TYPO3-mvc] Problems with nested page-objects

Stefan Frömken firma at sfroemken.de
Fri Sep 2 19:33:29 CEST 2011


Hello MVC-Team,

I have a PAGES-model with an additional value containing the childpages 
of the next level:

/**
  * page
  *
  * @var 
Tx_Extbase_Persistence_ObjectStorage<Tx_KeAggregatedcontent_Domain_Model_Pages>
  */
protected $pages;

You see: It's an objectStorage!!!

Now I have something like this in my Repository (simplified):

public function getNestedPages($uid) {
	$query = $this->createQuery();
	$result = $query->matching($query->equals('pid', $uid))->execute();
	
	foreach($result as $object) {
	$object->setPages($this->getNestedPages($object->getUid()));
	}
	return $result;
}

Now extbase throws exceptions because setPages() needs type 
Tx_Extbase_Persistence_ObjectStorage...but is of type 
Tx_Extbase_Persistende_QueryResult

Any ideas?

For now I have solved it this way...but I hope you have a better 
solution for me:

public function getNestedPages($uid) {
	$localStorage = new Tx_Extbase_Persistence_ObjectStorage();
	$query = $this->createQuery();
	foreach($query->matching($query->equals('pid', $uid))->execute() as 
$object) {
	$object->setPages($this->getNestedPages($object->getUid()));
		$localStorage->attach($object);
	}
	return $localStorage;
}

Stefan


More information about the TYPO3-project-typo3v4mvc mailing list