Reputation: 13
My extbase model "show", has got a lot of records "production". A Production can be "ended" or "current". It's declared in the Model of productions.
In a "Show"-Show I want to list the current productions and the ended ones. Currently it's only possible to list it with <f:for each="{productions}"...>
and a condition.
But I want to do it like in this way <f:for each="{currentProductions}"...
or <f:for each="{endedProductions}"...
So I wrote a query for my repository of productions:
public function aktuelleProduktionen(Musicalplanet\MpDatenbank\Domain\Model\Produktionen $produktionen) {
$query = $this->createQuery();
$query->matching(
$query->logicalOr(
$query->equals('openend', '1'),
$query->equals('abgelaufen', '0')
)
);
return $query->execute();
}
but now I really don't know how to make it working. For me it's not clear where to add it, to use it like I need it.
Upvotes: 0
Views: 89
Reputation: 534
First of all, I think your query method should be more like this to get the productions of a show:
public function aktuelleProduktionen(Musicalplanet\MpDatenbank\Domain\Model\Show $show) {
$query = $this->createQuery();
$query->matching(
$query->logicalAnd(
$query->equals('show', $show->getUid()),
$query->logicalOr(
$query->equals('openend', '1'),
$query->equals('abgelaufen', '0')
)
)
);
return $query->execute();
}
I guess, when you have a show-Model, you have a Show-Controller, too. Inside that, you should inject your ProductionRepository:
/**
* programRepository
*
* @var \Musicalplanet\MpDatenbank\Domain\Model\ProduktionenRepository
* @inject
*/
protected $produktionenRepository;
Now you can use your custom query method to get your current productions out of that Repository. Do that in your showAction().
public function showAction(Musicalplanet\MpDatenbank\Domain\Model\Show $show) {
$currentProductions = $this->produktionenRepository->aktuelleProduktionen($show);
$this->view->assign('currentProductions', $currentProductions);
}
More or less, this should work. Hope that helps.
Upvotes: 1