Code Duplication    Length = 45-46 lines in 2 locations

src/Eccube/Repository/PageLayoutRepository.php 2 locations

@@ 72-117 (lines=46) @@
69
            ->getResult();
70
    }
71
72
    public function get(DeviceType $DeviceType, $pageId)
73
    {
74
        $qb = $this->createQueryBuilder('p')
75
            ->select('p, bp, b')
76
            ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')
77
            ->leftJoin('bp.Block', 'b')
78
            ->andWhere('p.DeviceType = :DeviceType AND p.id = :pageId')
79
            ->addOrderBy('bp.target_id', 'ASC')
80
            ->addOrderBy('bp.block_row', 'ASC');
81
82
        $ownResult = $qb
83
            ->getQuery()
84
            ->setParameters(array(
85
                'DeviceType'  => $DeviceType,
86
                'pageId'        => $pageId,
87
            ))
88
            ->getSingleResult();
89
90
        $qb = $this->createQueryBuilder('p')
91
            ->select('p, bp, b')
92
            ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')
93
            ->leftJoin('bp.Block', 'b')
94
            ->andWhere('p.DeviceType = :DeviceType AND bp.anywhere = 1')
95
            ->addOrderBy('bp.target_id', 'ASC')
96
            ->addOrderBy('bp.block_row', 'ASC');
97
98
        $anyResults = $qb
99
            ->getQuery()
100
            ->setParameters(array(
101
                'DeviceType' => $DeviceType,
102
            ))
103
            ->getResult();
104
105
        $OwnBlockPosition = $ownResult->getBlockPositions();
106
        foreach ($anyResults as $anyResult) {
107
            $BlockPositions = $anyResult->getBlockPositions();
108
            foreach ($BlockPositions as $BlockPosition) {
109
                if (!$OwnBlockPosition->contains($BlockPosition)) {
110
                    $ownResult->addBlockPosition($BlockPosition);
111
                }
112
            }
113
        }
114
115
        return $ownResult;
116
117
    }
118
119
    public function getByUrl(DeviceType $DeviceType, $url)
120
    {
@@ 119-163 (lines=45) @@
116
117
    }
118
119
    public function getByUrl(DeviceType $DeviceType, $url)
120
    {
121
        $qb = $this->createQueryBuilder('p')
122
            ->select('p, bp, b')
123
            ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')
124
            ->leftJoin('bp.Block', 'b')
125
            ->andWhere('p.DeviceType = :DeviceType AND p.url = :url')
126
            ->addOrderBy('bp.target_id', 'ASC')
127
            ->addOrderBy('bp.block_row', 'ASC');
128
129
        $ownResult = $qb
130
            ->getQuery()
131
            ->setParameters(array(
132
                'DeviceType' => $DeviceType,
133
                'url'  => $url,
134
            ))
135
            ->getSingleResult();
136
137
        $qb = $this->createQueryBuilder('p')
138
            ->select('p, bp, b')
139
            ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')
140
            ->leftJoin('bp.Block', 'b')
141
            ->andWhere('p.DeviceType = :DeviceType AND bp.anywhere = 1')
142
            ->addOrderBy('bp.target_id', 'ASC')
143
            ->addOrderBy('bp.block_row', 'ASC');
144
145
        $anyResults = $qb
146
            ->getQuery()
147
            ->setParameters(array(
148
                'DeviceType' => $DeviceType,
149
            ))
150
            ->getResult();
151
152
        $OwnBlockPosition = $ownResult->getBlockPositions();
153
        foreach ($anyResults as $anyResult) {
154
            $BlockPositions = $anyResult->getBlockPositions();
155
            foreach ($BlockPositions as $BlockPosition) {
156
                if (!$OwnBlockPosition->contains($BlockPosition)) {
157
                    $ownResult->addBlockPosition($BlockPosition);
158
                }
159
            }
160
        }
161
162
        return $ownResult;
163
    }
164
165
    public function newPageLayout(DeviceType $DeviceType)
166
    {