0

I used the extension builder to generate a base for my extension. But now I want to modify the output of my listAction() method:

public function listAction() {
    $rooms = $this->roomRepository->findAll();
            $this->view->assign('rooms', $rooms);
}

Is it possible to add a where statement to not receive all rows from table "Rooms"?

pdu
  • 10,295
  • 4
  • 58
  • 95
PilsenDude
  • 21
  • 2

1 Answers1

1

You can just add custom methods into your repository for advanced querying the DB like described in the blog post

sample:

public function findRecentByBlog(Tx_BlogExample_Domain_Model_Blog $blog, $limit = 5) {
    $query = $this->createQuery();
    return $query->matching($query->equals('blog', $blog))
        ->setOrderings(array('date' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING))
        ->setLimit((integer)$limit)
        ->execute();
}

so you can use it in controller like:

$posts = $this->postRepository->findRecentByBlog($blog, 3);
biesior
  • 55,576
  • 10
  • 125
  • 182