Skip to content

Instantly share code, notes, and snippets.

@derhansen
Created April 21, 2014 13:11
Show Gist options
  • Save derhansen/11142338 to your computer and use it in GitHub Desktop.
Save derhansen/11142338 to your computer and use it in GitHub Desktop.
Random sorting of QueryResults in TYPO3 6.2
<?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