1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Silverback API Components Bundle Project |
5
|
|
|
* |
6
|
|
|
* (c) Daniel West <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Silverback\ApiComponentsBundle\Repository\Core; |
15
|
|
|
|
16
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
17
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
18
|
|
|
use Silverback\ApiComponentsBundle\Entity\Core\ComponentInterface; |
19
|
|
|
use Silverback\ApiComponentsBundle\Entity\Core\ComponentPosition; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Daniel West <[email protected]> |
23
|
|
|
* |
24
|
|
|
* @method ComponentPosition|null find($id, $lockMode = null, $lockVersion = null) |
25
|
|
|
* @method ComponentPosition|null findOneBy(array $criteria, array $orderBy = null) |
26
|
|
|
* @method ComponentPosition[] findAll() |
27
|
|
|
* @method ComponentPosition[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
28
|
|
|
*/ |
29
|
|
|
class ComponentPositionRepository extends ServiceEntityRepository |
30
|
|
|
{ |
31
|
|
|
public function __construct(ManagerRegistry $registry) |
32
|
|
|
{ |
33
|
|
|
parent::__construct($registry, ComponentPosition::class); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function findByComponent(ComponentInterface $component): array |
37
|
|
|
{ |
38
|
|
|
return $this->findBy([ |
39
|
|
|
'component' => $component, |
40
|
|
|
]); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function findByPageDataProperties(array $properties): array |
44
|
|
|
{ |
45
|
|
|
$qb = $this->createQueryBuilder('pd'); |
46
|
|
|
$expr = $qb->expr(); |
47
|
|
|
foreach ($properties as $index => $property) { |
48
|
|
|
$key = sprintf(':positionName%d', $index); |
49
|
|
|
$qb->orWhere($expr->eq('pd.pageDataProperty', $key)); |
50
|
|
|
$qb->setParameter($key, $property); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return $qb->getQuery()->getResult(); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|