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\ORM\Query\Expr\Join; |
18
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
19
|
|
|
use Silverback\ApiComponentsBundle\Entity\Core\AbstractComponent; |
20
|
|
|
use Silverback\ApiComponentsBundle\Entity\Core\AbstractPageData; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @author Daniel West <[email protected]> |
24
|
|
|
* |
25
|
|
|
* @method AbstractPageData|null find($id, $lockMode = null, $lockVersion = null) |
26
|
|
|
* @method AbstractPageData|null findOneBy(array $criteria, array $orderBy = null) |
27
|
|
|
* @method AbstractPageData[] findAll() |
28
|
|
|
* @method AbstractPageData[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
29
|
|
|
*/ |
30
|
|
|
class AbstractPageDataRepository extends ServiceEntityRepository |
31
|
|
|
{ |
32
|
|
|
public function __construct(ManagerRegistry $registry) |
33
|
|
|
{ |
34
|
|
|
parent::__construct($registry, AbstractPageData::class); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return AbstractPageData[] |
39
|
|
|
*/ |
40
|
|
|
public function findByNestedComponent(AbstractComponent $component): array |
41
|
|
|
{ |
42
|
|
|
$queryBuilder = $this->createQueryBuilder('pageData'); |
43
|
|
|
$queryBuilder |
44
|
|
|
->leftJoin( |
45
|
|
|
'pageData.page', |
46
|
|
|
'pageData_page', |
47
|
|
|
Join::WITH, |
48
|
|
|
$queryBuilder->expr()->eq('pageData_page', 'pageData.page') |
49
|
|
|
) |
50
|
|
|
->leftJoin( |
51
|
|
|
'pageData_page.componentCollections', |
52
|
|
|
'page_data_cc' |
53
|
|
|
) |
54
|
|
|
->leftJoin( |
55
|
|
|
'page_data_cc.componentPositions', |
56
|
|
|
'page_data_pos' |
57
|
|
|
) |
58
|
|
|
->leftJoin( |
59
|
|
|
'page_data_pos.component', |
60
|
|
|
'page_data_component', |
61
|
|
|
Join::WITH, |
62
|
|
|
$queryBuilder->expr()->eq('page_data_pos.component', 'page_data_component') |
63
|
|
|
) |
64
|
|
|
->andWhere( |
65
|
|
|
$queryBuilder->expr()->eq('page_data_component', ':component') |
66
|
|
|
) |
67
|
|
|
->setParameter('component', $component); |
68
|
|
|
|
69
|
|
|
return $queryBuilder->getQuery()->getResult(); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|