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

LayoutRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 18 2
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