| Total Complexity | 4 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class BannerRepository extends EntityRepository implements BannerRepositoryInterface |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * {@inheritdoc} |
||
| 16 | */ |
||
| 17 | public function findByEnabledQueryBuilder(ChannelInterface $channel, TaxonInterface $taxon = null): QueryBuilder |
||
| 18 | { |
||
| 19 | $queryBuilder = $this->createQueryBuilder('b') |
||
| 20 | ->innerJoin('b.channels', 'channel') |
||
| 21 | ->andWhere('b.enabled = :enabled') |
||
| 22 | ->andWhere('channel = :channel') |
||
| 23 | ->setParameter('channel', $channel) |
||
| 24 | ->setParameter('enabled', true) |
||
| 25 | ; |
||
| 26 | |||
| 27 | if ($taxon) { |
||
| 28 | $queryBuilder->innerJoin('b.taxons', 'taxon') |
||
| 29 | ->andWhere('taxon = :taxon') |
||
| 30 | ->setParameter('taxon', $taxon) |
||
| 31 | ; |
||
| 32 | } |
||
| 33 | |||
| 34 | return $queryBuilder; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * {@inheritdoc} |
||
| 39 | */ |
||
| 40 | public function findByChannel(ChannelInterface $channel): array |
||
| 41 | { |
||
| 42 | return $this->findByEnabledQueryBuilder($channel)->getQuery()->getResult(); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * {@inheritdoc} |
||
| 47 | */ |
||
| 48 | public function findByChannelAndTaxon(ChannelInterface $channel, TaxonInterface $taxon): array |
||
| 51 | } |
||
| 52 | } |
||
| 53 |