[TYPO3-mvc] Sorting children (object storage) again
Philipp Wrann
philippwrann at gmail.com
Wed Sep 30 12:38:47 CEST 2015
The ordering is determined by the child configuration, i would try to use a MM Table to store the relation with ordering, that way extbase should take the ordering into account when loading the relations.
A very dirty way would be:
Define the property as string (so 1,2,3 is mapped as relationvalue) and add a getter working like:
public function getRelations() {
// fix class name to fully qualified version
$objectManager = GeneralUtility::makeInstance('ObjectManager');
// fix class name to fully qualified version
$repository = $objectManager->get('RepositoryClassName');
$return = array();
$query = $repository->createQuery();
$query->matching($query->in('uid',explode(',',$this->relations));
// force extbase do the mapping and register the objects in peristenceSession
$result = $query->execute()->toArray();
foreach (explode(',',$this->relations) as $uid) {
// second query should not be created, because the identifier has allready been loaded and registered
$return[] = $repository->findByUid($uid);
}
return $return;
}
But - as mentioned this is very dirty, i would go for the version with the intermediate table holding the orderings.
More information about the TYPO3-project-typo3v4mvc
mailing list