Skip to content

Instantly share code, notes, and snippets.

@noelboss
Created November 9, 2012 08:44
Show Gist options
  • Select an option

  • Save noelboss/4044511 to your computer and use it in GitHub Desktop.

Select an option

Save noelboss/4044511 to your computer and use it in GitHub Desktop.

Revisions

  1. noelboss revised this gist Nov 9, 2012. 3 changed files with 39 additions and 8 deletions.
    38 changes: 38 additions & 0 deletions child-repository.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    /**
    *
    *
    * @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;
    }
    }
    1 change: 1 addition & 0 deletions parent-model-new.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@

    /**
    * Returns the events
    *
    8 changes: 0 additions & 8 deletions parent-model.php
    Original file line number Diff line number Diff line change
    @@ -1,8 +0,0 @@
    /**
    * Returns the events
    *
    * @return Tx_Extbase_Persistence_ObjectStorage<Tx_Nboevents_Domain_Model_Event> $events
    */
    public function getEvents() {
    $this->events;
    }
  2. noelboss revised this gist Nov 9, 2012. 2 changed files with 8 additions and 38 deletions.
    8 changes: 8 additions & 0 deletions parent-model.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    /**
    * Returns the events
    *
    * @return Tx_Extbase_Persistence_ObjectStorage<Tx_Nboevents_Domain_Model_Event> $events
    */
    public function getEvents() {
    $this->events;
    }
    38 changes: 0 additions & 38 deletions repository.php
    Original file line number Diff line number Diff line change
    @@ -1,38 +0,0 @@
    /**
    *
    *
    * @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;
    }
    }
  3. noelboss created this gist Nov 9, 2012.
    19 changes: 19 additions & 0 deletions parent-model-new.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    /**
    * 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);
    }
    38 changes: 38 additions & 0 deletions repository.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    /**
    *
    *
    * @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;
    }
    }