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

BlockRepository::getUnusedBlocks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 11
ccs 0
cts 1
cp 0
crap 2
rs 9.9
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\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
    /**
81
     * 未設定のブロックを取得
82
     *
83
     * @param  Ecube\Entity\Block[]  $Blocks
84
     *
85
     * @return null|Ecube\Entity\Block[]
86
     */
87
    public function getUnusedBlocks($Blocks)
88
    {
89
        $UnusedBlocks = $this->createQueryBuilder('b')
90
            ->select('b')
91
            ->where('b not in (:blocks)')
92
            ->setParameter('blocks', $Blocks)
93
            ->getQuery()
94
            ->getResult();
95
96
        return $UnusedBlocks;
97
    }
98
}
99