Created
April 21, 2014 13:11
-
-
Save derhansen/11142338 to your computer and use it in GitHub Desktop.
Random sorting of QueryResults in TYPO3 6.2
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
<?php | |
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult; | |
class RandomQueryResult extends QueryResult { | |
/** | |
* Keeps track of, if queryResult has been shuffled | |
*/ | |
protected $shuffled = FALSE; | |
/** | |
* Loads the objects this QueryResult is supposed to hold | |
* | |
* @return void | |
*/ | |
protected function initialize() { | |
parent::initialize(); | |
if (!$this->shuffled) { | |
shuffle($this->queryResult); | |
$this->shuffled = TRUE; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment