0
votes

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.

1
Could you please be more specific about "where to add it and use it"? What did you try?Ami Tavory
(Off-topic) try to avoid naming methods in non-English - you'll avoid language-monsters like getProduktFromKorb ;) and also it will be easier for us to help youbiesior

1 Answers

1
votes

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.