| @@ 60-89 (lines=30) @@ | ||
| 57 | * @param \Eccube\Entity\ClassName $ClassName |
|
| 58 | * @return boolean 成功した場合 true |
|
| 59 | */ |
|
| 60 | public function up(\Eccube\Entity\ClassName $ClassName) |
|
| 61 | { |
|
| 62 | $em = $this->getEntityManager(); |
|
| 63 | $em->getConnection()->beginTransaction(); |
|
| 64 | try { |
|
| 65 | $rank = $ClassName->getRank(); |
|
| 66 | ||
| 67 | // |
|
| 68 | $ClassName2 = $this->findOneBy(array('rank' => $rank + 1)); |
|
| 69 | if (!$ClassName2) { |
|
| 70 | throw new \Exception(); |
|
| 71 | } |
|
| 72 | $ClassName2->setRank($rank); |
|
| 73 | $em->persist($ClassName); |
|
| 74 | ||
| 75 | // ClassName更新 |
|
| 76 | $ClassName->setRank($rank + 1); |
|
| 77 | ||
| 78 | $em->persist($ClassName); |
|
| 79 | $em->flush(); |
|
| 80 | ||
| 81 | $em->getConnection()->commit(); |
|
| 82 | } catch (\Exception $e) { |
|
| 83 | $em->getConnection()->rollback(); |
|
| 84 | ||
| 85 | return false; |
|
| 86 | } |
|
| 87 | ||
| 88 | return true; |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * 規格の順位を1下げる. |
|
| @@ 97-126 (lines=30) @@ | ||
| 94 | * @param \Eccube\Entity\ClassName $ClassName |
|
| 95 | * @return boolean 成功した場合 true |
|
| 96 | */ |
|
| 97 | public function down(\Eccube\Entity\ClassName $ClassName) |
|
| 98 | { |
|
| 99 | $em = $this->getEntityManager(); |
|
| 100 | $em->getConnection()->beginTransaction(); |
|
| 101 | try { |
|
| 102 | $rank = $ClassName->getRank(); |
|
| 103 | ||
| 104 | // |
|
| 105 | $ClassName2 = $this->findOneBy(array('rank' => $rank - 1)); |
|
| 106 | if (!$ClassName2) { |
|
| 107 | throw new \Exception(); |
|
| 108 | } |
|
| 109 | $ClassName2->setRank($rank); |
|
| 110 | $em->persist($ClassName); |
|
| 111 | ||
| 112 | // ClassName更新 |
|
| 113 | $ClassName->setRank($rank - 1); |
|
| 114 | ||
| 115 | $em->persist($ClassName); |
|
| 116 | $em->flush(); |
|
| 117 | ||
| 118 | $em->getConnection()->commit(); |
|
| 119 | } catch (\Exception $e) { |
|
| 120 | $em->getConnection()->rollback(); |
|
| 121 | ||
| 122 | return false; |
|
| 123 | } |
|
| 124 | ||
| 125 | return true; |
|
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * 規格を保存する. |
|
| @@ 139-167 (lines=29) @@ | ||
| 136 | * |
|
| 137 | * @return void |
|
| 138 | */ |
|
| 139 | public function up(\Eccube\Entity\Member $Member) |
|
| 140 | { |
|
| 141 | $em = $this->getEntityManager(); |
|
| 142 | $em->getConnection()->beginTransaction(); |
|
| 143 | try { |
|
| 144 | $rank = $Member->getRank(); |
|
| 145 | ||
| 146 | $Member2 = $this->findOneBy(array('rank' => $rank + 1)); |
|
| 147 | if (!$Member2) { |
|
| 148 | throw new \Exception(); |
|
| 149 | } |
|
| 150 | $Member2->setRank($rank); |
|
| 151 | $em->persist($Member2); |
|
| 152 | ||
| 153 | // Member更新 |
|
| 154 | $Member->setRank($rank + 1); |
|
| 155 | ||
| 156 | $em->persist($Member); |
|
| 157 | $em->flush(); |
|
| 158 | ||
| 159 | $em->getConnection()->commit(); |
|
| 160 | } catch (\Exception $e) { |
|
| 161 | $em->getConnection()->rollback(); |
|
| 162 | ||
| 163 | return false; |
|
| 164 | } |
|
| 165 | ||
| 166 | return true; |
|
| 167 | } |
|
| 168 | ||
| 169 | /** |
|
| 170 | * @param \Eccube\Entity\Member $Member |
|
| @@ 173-202 (lines=30) @@ | ||
| 170 | * @param \Eccube\Entity\Member $Member |
|
| 171 | * @return bool |
|
| 172 | */ |
|
| 173 | public function down(\Eccube\Entity\Member $Member) |
|
| 174 | { |
|
| 175 | $em = $this->getEntityManager(); |
|
| 176 | $em->getConnection()->beginTransaction(); |
|
| 177 | try { |
|
| 178 | $rank = $Member->getRank(); |
|
| 179 | ||
| 180 | // |
|
| 181 | $Member2 = $this->findOneBy(array('rank' => $rank - 1)); |
|
| 182 | if (!$Member2) { |
|
| 183 | throw new \Exception(); |
|
| 184 | } |
|
| 185 | $Member2->setRank($rank); |
|
| 186 | $em->persist($Member2); |
|
| 187 | ||
| 188 | // Member更新 |
|
| 189 | $Member->setRank($rank - 1); |
|
| 190 | ||
| 191 | $em->persist($Member); |
|
| 192 | $em->flush(); |
|
| 193 | ||
| 194 | $em->getConnection()->commit(); |
|
| 195 | } catch (\Exception $e) { |
|
| 196 | $em->getConnection()->rollback(); |
|
| 197 | ||
| 198 | return false; |
|
| 199 | } |
|
| 200 | ||
| 201 | return true; |
|
| 202 | } |
|
| 203 | ||
| 204 | /** |
|
| 205 | * @param \Eccube\Entity\Member $Member |
|
| @@ 46-74 (lines=29) @@ | ||
| 43 | * @param \Eccube\Entity\News $News |
|
| 44 | * @return boolean 成功した場合 true |
|
| 45 | */ |
|
| 46 | public function up(\Eccube\Entity\News $News) |
|
| 47 | { |
|
| 48 | $em = $this->getEntityManager(); |
|
| 49 | $em->getConnection()->beginTransaction(); |
|
| 50 | try { |
|
| 51 | $rank = $News->getRank(); |
|
| 52 | ||
| 53 | $News2 = $this->findOneBy(array('rank' => $rank + 1)); |
|
| 54 | if (!$News2) { |
|
| 55 | throw new \Exception(); |
|
| 56 | } |
|
| 57 | $News2->setRank($rank); |
|
| 58 | $em->persist($News2); |
|
| 59 | ||
| 60 | // News更新 |
|
| 61 | $News->setRank($rank + 1); |
|
| 62 | ||
| 63 | $em->persist($News); |
|
| 64 | $em->flush(); |
|
| 65 | ||
| 66 | $em->getConnection()->commit(); |
|
| 67 | } catch (\Exception $e) { |
|
| 68 | $em->getConnection()->rollback(); |
|
| 69 | ||
| 70 | return false; |
|
| 71 | } |
|
| 72 | ||
| 73 | return true; |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * News の順位を1下げる |
|
| @@ 82-109 (lines=28) @@ | ||
| 79 | * @param \Eccube\Entity\News $News |
|
| 80 | * @return boolean 成功した場合 true |
|
| 81 | */ |
|
| 82 | public function down(\Eccube\Entity\News $News) |
|
| 83 | { |
|
| 84 | $em = $this->getEntityManager(); |
|
| 85 | $em->getConnection()->beginTransaction(); |
|
| 86 | try { |
|
| 87 | $rank = $News->getRank(); |
|
| 88 | $News2 = $this->findOneBy(array('rank' => $rank - 1)); |
|
| 89 | if (!$News2) { |
|
| 90 | throw new \Exception(); |
|
| 91 | } |
|
| 92 | $News2->setRank($rank); |
|
| 93 | $em->persist($News2); |
|
| 94 | ||
| 95 | // News更新 |
|
| 96 | $News->setRank($rank - 1); |
|
| 97 | ||
| 98 | $em->persist($News); |
|
| 99 | $em->flush(); |
|
| 100 | ||
| 101 | $em->getConnection()->commit(); |
|
| 102 | } catch (\Exception $e) { |
|
| 103 | $em->getConnection()->rollback(); |
|
| 104 | ||
| 105 | return false; |
|
| 106 | } |
|
| 107 | ||
| 108 | return true; |
|
| 109 | } |
|
| 110 | ||
| 111 | /** |
|
| 112 | * News を保存する. |
|