Completed
Push — master ( f6198e...300d99 )
by Paweł
53:20
created

ContainerWidgetRepository::getSortedWidgets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Templates System Bundle.
7
 *
8
 * Copyright 2015 Sourcefabric z.u. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2015 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\TemplatesSystemBundle\Repository;
18
19
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository;
20
use SWP\Component\TemplatesSystem\Gimme\Model\ContainerInterface;
21
use SWP\Component\TemplatesSystem\Repository\ContainerWidgetRepositoryInterface;
22
23
/**
24
 * ContainerWidget Repository.
25
 */
26
class ContainerWidgetRepository extends EntityRepository implements ContainerWidgetRepositoryInterface
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function findSortedWidgets(ContainerInterface $container): array
32
    {
33
        return $this->createQueryBuilder('n')
34
            ->select('n', 'w')
35
            ->leftJoin('n.widget', 'w')
36
            ->where('n.container = :container')
37
            ->setParameter('container', $container)
38
            ->addOrderBy('n.position')
39
            ->getQuery()
40
            ->getResult()
41
        ;
42
    }
43
}
44