Last active
October 10, 2019 13:07
-
-
Save benjaminrau/6493475 to your computer and use it in GitHub Desktop.
Fill ObjectStorage from QueryResult
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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