Completed
Pull Request — 4.0 (#3658)
by Kentaro
06:26
created

BlockRepository::getPageList()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 21

Duplication

Lines 21
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 3
dl 21
loc 21
rs 9.584
c 0
b 0
f 0
ccs 0
cts 14
cp 0
crap 12
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\Common\EccubeConfig;
17
use Eccube\Entity\Block;
18
use Eccube\Entity\Master\DeviceType;
19
use Symfony\Bridge\Doctrine\RegistryInterface;
20
21
/**
22
 * BlocRepository
23
 *
24
 * This class was generated by the Doctrine ORM. Add your own custom
25
 * repository methods below.
26
 */
27
class BlockRepository extends AbstractRepository
28
{
29
    /**
30
     * @var EccubeConfig
31
     */
32
    protected $eccubeConfig;
33
34
    /**
35
     * BlockRepository constructor.
36
     *
37
     * @param RegistryInterface $registry
38
     * @param EccubeConfig $eccubeConfig
39
     */
40 14
    public function __construct(
41
        RegistryInterface $registry,
42
        EccubeConfig $eccubeConfig
43
    ) {
44 14
        parent::__construct($registry, Block::class);
45 14
        $this->eccubeConfig = $eccubeConfig;
46
    }
47
48
    public function newBlock($DeviceType)
49
    {
50
        $Block = new \Eccube\Entity\Block();
51
        $Block
52
            ->setDeviceType($DeviceType)
53
            ->setUseController(false)
54
            ->setDeletable(true);
55
56 3
        return $Block;
57
    }
58 3
59 1
    /**
60
     * ブロック一覧の取得.
61 3
     *
62
     * @param  \Eccube\Entity\Master\DeviceType $DeviceType
63
     *
64
     * @return null|\Symfony\Component\HttpFoundation\Request
65 1
     */
66
    public function getList($DeviceType)
67 1
    {
68
        $qb = $this->createQueryBuilder('b')
69 1
            ->orderBy('b.id', 'DESC')
70 1
            ->where('b.DeviceType = :DeviceType')
71 1
            ->setParameter('DeviceType', $DeviceType);
72
73 1
        $Blocks = $qb
74
            ->getQuery()
75
            ->getResult();
76
77
        return $Blocks;
78
    }
79
}
80