Failed Conditions
Push — dev/plugin-misc ( f22d99...066a4d )
by Kiyotaka
10:54 queued 03:43
created

LayoutRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 28
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 20 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 Doctrine\ORM\NoResultException;
17
use Eccube\Entity\Layout;
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
{
28
    public function __construct(RegistryInterface $registry)
29
    {
30
        parent::__construct($registry, Layout::class);
31
    }
32
33
    public function get($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 = :id')
41
                ->orderBy('bp.block_row', 'ASC')
42
                ->setParameter('id', $id)
43
                ->getQuery()
44
                ->useResultCache(true, $this->getCacheLifetime())
45
                ->getSingleResult();
46
47
        } catch (NoResultException $e) {
48
            return null;
49
        }
50
51
        return $Layout;
52
    }
53
}
54