| @@ 158-203 (lines=46) @@ | ||
| 155 | * @param $productClassId |
|
| 156 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
|
| 157 | */ |
|
| 158 | public function up(Application $app, Request $request, $productClassId) |
|
| 159 | { |
|
| 160 | $this->isTokenValid($app); |
|
| 161 | ||
| 162 | // FRONT_CART_UP_INITIALIZE |
|
| 163 | $event = new EventArgs( |
|
| 164 | array('productClassId' => $productClassId,), |
|
| 165 | $request |
|
| 166 | ); |
|
| 167 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_INITIALIZE, $event); |
|
| 168 | ||
| 169 | try { |
|
| 170 | ||
| 171 | $productClassId = $event->getArgument('productClassId'); |
|
| 172 | ||
| 173 | $app['eccube.service.cart']->upProductQuantity($productClassId)->save(); |
|
| 174 | ||
| 175 | // FRONT_CART_UP_COMPLETE |
|
| 176 | $event = new EventArgs( |
|
| 177 | array('productClassId' => $productClassId,), |
|
| 178 | $request |
|
| 179 | ); |
|
| 180 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_COMPLETE, $event); |
|
| 181 | ||
| 182 | if ($event->hasResponse()) { |
|
| 183 | return $event->getResponse(); |
|
| 184 | } |
|
| 185 | ||
| 186 | } catch (CartException $e) { |
|
| 187 | ||
| 188 | // FRONT_CART_UP_EXCEPTION |
|
| 189 | $event = new EventArgs( |
|
| 190 | array('exception' => $e,), |
|
| 191 | $request |
|
| 192 | ); |
|
| 193 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_EXCEPTION, $event); |
|
| 194 | ||
| 195 | if ($event->hasResponse()) { |
|
| 196 | return $event->getResponse(); |
|
| 197 | } |
|
| 198 | ||
| 199 | $app->addRequestError($e->getMessage()); |
|
| 200 | } |
|
| 201 | ||
| 202 | return $app->redirect($app->url('cart')); |
|
| 203 | } |
|
| 204 | ||
| 205 | /** |
|
| 206 | * カートに入っている商品の個数を1減らす. |
|
| @@ 214-257 (lines=44) @@ | ||
| 211 | * @param $productClassId |
|
| 212 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
|
| 213 | */ |
|
| 214 | public function down(Application $app, Request $request, $productClassId) |
|
| 215 | { |
|
| 216 | $this->isTokenValid($app); |
|
| 217 | ||
| 218 | // FRONT_CART_DOWN_INITIALIZE |
|
| 219 | $event = new EventArgs( |
|
| 220 | array('productClassId' => $productClassId,), |
|
| 221 | $request |
|
| 222 | ); |
|
| 223 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_INITIALIZE, $event); |
|
| 224 | ||
| 225 | try { |
|
| 226 | $productClassId = $event->getArgument('productClassId'); |
|
| 227 | $app['eccube.service.cart']->downProductQuantity($productClassId)->save(); |
|
| 228 | ||
| 229 | // FRONT_CART_UP_COMPLETE |
|
| 230 | $event = new EventArgs( |
|
| 231 | array('productClassId' => $productClassId,), |
|
| 232 | $request |
|
| 233 | ); |
|
| 234 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_COMPLETE, $event); |
|
| 235 | ||
| 236 | if ($event->hasResponse()) { |
|
| 237 | return $event->getResponse(); |
|
| 238 | } |
|
| 239 | ||
| 240 | } catch (CartException $e) { |
|
| 241 | ||
| 242 | // FRONT_CART_DOWN_EXCEPTION |
|
| 243 | $event = new EventArgs( |
|
| 244 | array('Exception' => $e,), |
|
| 245 | $request |
|
| 246 | ); |
|
| 247 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_EXCEPTION, $event); |
|
| 248 | ||
| 249 | if ($event->hasResponse()) { |
|
| 250 | return $event->getResponse(); |
|
| 251 | } |
|
| 252 | ||
| 253 | $app->addRequestError($e->getMessage()); |
|
| 254 | } |
|
| 255 | ||
| 256 | return $app->redirect($app->url('cart')); |
|
| 257 | } |
|
| 258 | ||
| 259 | /** |
|
| 260 | * カートに入っている商品を削除する. |
|