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

ComponentLocationRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findByDynamicPage() 0 10 1
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