[TYPO3-mvc] Sorting Extbase ObjectStorage

Felix Oertel mehl at foertel.com
Mon Jun 7 13:25:31 CEST 2010


Hey,

I'm sorry, but i'm really short on time somehow ... here is how i order 
child-records.

I got a Classes/Utility/Array.php

Tx_MyExt_Utility_Array
	static public function sortByName($array)
		-> usort($array, 'Tx_MyExt_Utility_Array::usortByName');
	static public function usortByName($a, $b)
		-> strnatcasecmp($a->getName(), $b->getName());

and in my model:

Tx_MyExt_Domain_Model_MyModel
	public function getForeignPropertyXY()
		-> return 
Tx_MyExt_Utility_Array::sortByName($this->properties->toArray());

Of course your ObjectStorage will be an array after that ... holding 
your child-objects. for me that is ok, as i don't use fe persistence.

hope that helps a little,

regards, foertel


More information about the TYPO3-project-typo3v4mvc mailing list