Created
November 9, 2012 08:44
-
-
Save noelboss/4044511 to your computer and use it in GitHub Desktop.
How to apply default sorting for child objects of the type Tx_Extbase_Persistence_ObjectStorage
This file contains hidden or 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
/** | |
* | |
* | |
* @package nboevents | |
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later | |
* | |
*/ | |
class Tx_Nboevents_Domain_Repository_EventRepository extends Tx_Extbase_Persistence_Repository { | |
/** | |
* defaultOrderings | |
* | |
* @var array | |
*/ | |
protected $defaultOrderings = array( | |
'date' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING, | |
); | |
/** | |
* findByCourse | |
* | |
* @param $uid | |
* @return | |
*/ | |
public function findByCourse($course = 0, $limit = 99) { | |
$now = time(); | |
$query = $this->createQuery(); | |
$query->matching( | |
$query->logicalAnd( | |
$query->equals('course', $course), | |
$query->greaterThanOrEqual('date', $now) | |
) | |
); | |
$query->setLimit((integer)$limit); | |
$posts = $query->execute(); | |
return $posts; | |
} | |
} |
This file contains hidden or 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
/** | |
* Returns the events | |
* | |
* @return Tx_Extbase_Persistence_ObjectStorage<Tx_Nboevents_Domain_Model_Event> $events | |
*/ | |
public function getEvents() { | |
$eventRepository = t3lib_div::makeInstance('Tx_Nboevents_Domain_Repository_EventRepository'); | |
return $eventRepository->findByCourse($this->getUid()); | |
} | |
/** | |
* Returns the next event | |
* | |
* @return Tx_Extbase_Persistence_ObjectStorage<Tx_Nboevents_Domain_Model_Event> $events | |
*/ | |
public function getNextevent() { | |
$eventRepository = t3lib_div::makeInstance('Tx_Nboevents_Domain_Repository_EventRepository'); | |
return $eventRepository->findByCourse($this->getUid(), 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment