Completed
Push — develop ( 87538f...e43479 )
by Daniel
07:02
created

ComponentLocationRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Repository;
4
5
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
6
use Silverback\ApiComponentBundle\Entity\Content\Component\ComponentLocation;
7
use Silverback\ApiComponentBundle\Entity\Content\Dynamic\AbstractDynamicPage;
8
use Symfony\Bridge\Doctrine\RegistryInterface;
9
10
class ComponentLocationRepository extends ServiceEntityRepository
11
{
12
    public function __construct(RegistryInterface $registry)
13
    {
14
        parent::__construct($registry, ComponentLocation::class);
15
    }
16
17
    public function findByDynamicPage(AbstractDynamicPage $page): array
18
    {
19
        $qb = $this->createQueryBuilder('location');
20
        $qb
21
            ->andWhere(
22
                $qb->expr()->eq('location.dynamicPageClass', ':cls')
23
            )
24
            ->setParameter('cls', \get_class($page))
25
        ;
26
        return $qb->getQuery()->getArrayResult();
27
    }
28
}
29