Skip to content

Instantly share code, notes, and snippets.

@benjaminrau
Last active October 10, 2019 13:07
Show Gist options
  • Save benjaminrau/6493475 to your computer and use it in GitHub Desktop.
Save benjaminrau/6493475 to your computer and use it in GitHub Desktop.
Fill ObjectStorage from QueryResult
$objectStorage = $this->fillOjectStorageFromQueryResult($this->myRepository->findAll()));
/**
* Fill objectStorage from QueryResult
*
* @param \TYPO3\CMS\Extbase\Persistence\QueryResultInterface $queryResult
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
protected function fillOjectStorageFromQueryResult(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface $queryResult=NULL) {
/* @var $objectStorage \TYPO3\CMS\Extbase\Persistence\ObjectStorage */
$objectStorage = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\ObjectStorage');
if (NULL!==$queryResult) {
foreach($queryResult AS $object) {
$objectStorage->attach($object);
}
}
return $objectStorage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment