Failed Conditions
Pull Request — 4.0 (#3831)
by Ryo
31:54 queued 17:09
created

LayoutRepository::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 18
ccs 0
cts 0
cp 0
crap 6
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Repository;
15
16
use Eccube\Entity\Layout;
17
use Doctrine\ORM\NoResultException;
18
use Symfony\Bridge\Doctrine\RegistryInterface;
19
20
/**
21
 * LayoutRepository
22
 *
23
 * This class was generated by the Doctrine ORM. Add your own custom
24
 * repository methods below.
25
 */
26
class LayoutRepository extends AbstractRepository
27 40
{
28
    public function __construct(RegistryInterface $registry)
29 40
    {
30
        parent::__construct($registry, Layout::class);
31
    }
32
33
    public function get($layout_id)
34
    {
35
        try {
36
            $Layout = $this->createQueryBuilder('l')
37
                ->select('l, bp, b')
38
                ->leftJoin('l.BlockPositions', 'bp')
39
                ->leftJoin('bp.Block', 'b')
40
                ->where('l.id = :layout_id')
41
                ->orderBy('bp.block_row', 'ASC')
42
                ->setParameter('layout_id', $layout_id)
43
                ->getQuery()
44
                ->getSingleResult();
45
        } catch (NoResultException $e) {
46
            return null;
47
        }
48
49
        return $Layout;
50
    }
51
}
52