@@ 168-197 (lines=30) @@ | ||
165 | * @param \Eccube\Entity\ClassName $ClassName |
|
166 | * @return boolean 成功した場合 true |
|
167 | */ |
|
168 | public function delete(\Eccube\Entity\ClassName $ClassName) |
|
169 | { |
|
170 | $em = $this->getEntityManager(); |
|
171 | $em->getConnection()->beginTransaction(); |
|
172 | try { |
|
173 | if ($ClassName->getClassCategories()->count() > 0) { |
|
174 | throw new \Exception(); |
|
175 | } |
|
176 | ||
177 | $rank = $ClassName->getRank(); |
|
178 | $em->createQueryBuilder() |
|
179 | ->update('Eccube\Entity\ClassName', 'cn') |
|
180 | ->set('cn.rank', 'cn.rank - 1') |
|
181 | ->where('cn.rank > :rank')->setParameter('rank', $rank) |
|
182 | ->getQuery() |
|
183 | ->execute(); |
|
184 | ||
185 | $ClassName->setDelFlg(1); |
|
186 | $em->persist($ClassName); |
|
187 | $em->flush(); |
|
188 | ||
189 | $em->getConnection()->commit(); |
|
190 | } catch (\Exception $e) { |
|
191 | $em->getConnection()->rollback(); |
|
192 | ||
193 | return false; |
|
194 | } |
|
195 | ||
196 | return true; |
|
197 | } |
|
198 | } |
|
199 |
@@ 150-177 (lines=28) @@ | ||
147 | * @param \Eccube\Entity\News $News |
|
148 | * @return boolean 成功した場合 true |
|
149 | */ |
|
150 | public function delete(\Eccube\Entity\News $News) |
|
151 | { |
|
152 | $em = $this->getEntityManager(); |
|
153 | $em->getConnection()->beginTransaction(); |
|
154 | try { |
|
155 | $rank = $News->getRank(); |
|
156 | $em->createQueryBuilder() |
|
157 | ->update('Eccube\Entity\News', 'n') |
|
158 | ->set('n.rank', 'n.rank - 1') |
|
159 | ->where('n.rank > :rank')->setParameter('rank', $rank) |
|
160 | ->getQuery() |
|
161 | ->execute(); |
|
162 | ||
163 | $News |
|
164 | ->setDelFlg(1) |
|
165 | ->setRank(0); |
|
166 | ||
167 | $em->persist($News); |
|
168 | $em->flush(); |
|
169 | ||
170 | $em->getConnection()->commit(); |
|
171 | } catch (\Exception $e) { |
|
172 | $em->getConnection()->rollback(); |
|
173 | return false; |
|
174 | } |
|
175 | ||
176 | return true; |
|
177 | } |
|
178 | } |
|
179 |
@@ 240-268 (lines=29) @@ | ||
237 | * @param \Eccube\Entity\Member $Member |
|
238 | * @return bool |
|
239 | */ |
|
240 | public function delete(\Eccube\Entity\Member $Member) |
|
241 | { |
|
242 | $em = $this->getEntityManager(); |
|
243 | $em->getConnection()->beginTransaction(); |
|
244 | try { |
|
245 | $rank = $Member->getRank(); |
|
246 | $em->createQueryBuilder() |
|
247 | ->update('Eccube\Entity\Member', 'm') |
|
248 | ->set('m.rank', 'm.rank - 1') |
|
249 | ->where('m.rank > :rank')->setParameter('rank', $rank) |
|
250 | ->getQuery() |
|
251 | ->execute(); |
|
252 | ||
253 | $Member |
|
254 | ->setDelFlg(Constant::ENABLED) |
|
255 | ->setRank(0); |
|
256 | ||
257 | $em->persist($Member); |
|
258 | $em->flush(); |
|
259 | ||
260 | $em->getConnection()->commit(); |
|
261 | } catch (\Exception $e) { |
|
262 | $em->getConnection()->rollback(); |
|
263 | ||
264 | return false; |
|
265 | } |
|
266 | ||
267 | return true; |
|
268 | } |
|
269 | ||
270 | /** |
|
271 | * saltを生成する |