| @@ 178-235 (lines=58) @@ | ||
| 175 | * @param $productClassId |
|
| 176 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
|
| 177 | */ |
|
| 178 | public function up(Application $app, Request $request, $productClassId) |
|
| 179 | { |
|
| 180 | $this->isTokenValid($app); |
|
| 181 | ||
| 182 | // FRONT_CART_UP_INITIALIZE |
|
| 183 | $event = new EventArgs( |
|
| 184 | array( |
|
| 185 | 'productClassId' => $productClassId, |
|
| 186 | ), |
|
| 187 | $request |
|
| 188 | ); |
|
| 189 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_INITIALIZE, $event); |
|
| 190 | ||
| 191 | try { |
|
| 192 | ||
| 193 | log_info('カート加算処理開始', array('product_class_id' => $productClassId)); |
|
| 194 | ||
| 195 | $productClassId = $event->getArgument('productClassId'); |
|
| 196 | ||
| 197 | $app['eccube.service.cart']->upProductQuantity($productClassId)->save(); |
|
| 198 | ||
| 199 | // FRONT_CART_UP_COMPLETE |
|
| 200 | $event = new EventArgs( |
|
| 201 | array( |
|
| 202 | 'productClassId' => $productClassId, |
|
| 203 | ), |
|
| 204 | $request |
|
| 205 | ); |
|
| 206 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_COMPLETE, $event); |
|
| 207 | ||
| 208 | if ($event->hasResponse()) { |
|
| 209 | return $event->getResponse(); |
|
| 210 | } |
|
| 211 | ||
| 212 | log_info('カート加算処理完了', array('product_class_id' => $productClassId)); |
|
| 213 | ||
| 214 | } catch (CartException $e) { |
|
| 215 | ||
| 216 | log_info('カート加算エラー', array($e->getMessage())); |
|
| 217 | ||
| 218 | // FRONT_CART_UP_EXCEPTION |
|
| 219 | $event = new EventArgs( |
|
| 220 | array( |
|
| 221 | 'exception' => $e, |
|
| 222 | ), |
|
| 223 | $request |
|
| 224 | ); |
|
| 225 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_EXCEPTION, $event); |
|
| 226 | ||
| 227 | if ($event->hasResponse()) { |
|
| 228 | return $event->getResponse(); |
|
| 229 | } |
|
| 230 | ||
| 231 | $app->addRequestError($e->getMessage()); |
|
| 232 | } |
|
| 233 | ||
| 234 | return $app->redirect($app->url('cart')); |
|
| 235 | } |
|
| 236 | ||
| 237 | /** |
|
| 238 | * カートに入っている商品の個数を1減らす. |
|
| @@ 246-301 (lines=56) @@ | ||
| 243 | * @param $productClassId |
|
| 244 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
|
| 245 | */ |
|
| 246 | public function down(Application $app, Request $request, $productClassId) |
|
| 247 | { |
|
| 248 | $this->isTokenValid($app); |
|
| 249 | ||
| 250 | // FRONT_CART_DOWN_INITIALIZE |
|
| 251 | $event = new EventArgs( |
|
| 252 | array( |
|
| 253 | 'productClassId' => $productClassId, |
|
| 254 | ), |
|
| 255 | $request |
|
| 256 | ); |
|
| 257 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_INITIALIZE, $event); |
|
| 258 | ||
| 259 | try { |
|
| 260 | ||
| 261 | log_info('カート減算処理開始', array('product_class_id' => $productClassId)); |
|
| 262 | ||
| 263 | $productClassId = $event->getArgument('productClassId'); |
|
| 264 | $app['eccube.service.cart']->downProductQuantity($productClassId)->save(); |
|
| 265 | ||
| 266 | // FRONT_CART_UP_COMPLETE |
|
| 267 | $event = new EventArgs( |
|
| 268 | array( |
|
| 269 | 'productClassId' => $productClassId, |
|
| 270 | ), |
|
| 271 | $request |
|
| 272 | ); |
|
| 273 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_COMPLETE, $event); |
|
| 274 | ||
| 275 | if ($event->hasResponse()) { |
|
| 276 | return $event->getResponse(); |
|
| 277 | } |
|
| 278 | ||
| 279 | log_info('カート減算処理完了', array('product_class_id' => $productClassId)); |
|
| 280 | ||
| 281 | } catch (CartException $e) { |
|
| 282 | log_info('カート減算エラー', array($e->getMessage())); |
|
| 283 | ||
| 284 | // FRONT_CART_DOWN_EXCEPTION |
|
| 285 | $event = new EventArgs( |
|
| 286 | array( |
|
| 287 | 'exception' => $e, |
|
| 288 | ), |
|
| 289 | $request |
|
| 290 | ); |
|
| 291 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_EXCEPTION, $event); |
|
| 292 | ||
| 293 | if ($event->hasResponse()) { |
|
| 294 | return $event->getResponse(); |
|
| 295 | } |
|
| 296 | ||
| 297 | $app->addRequestError($e->getMessage()); |
|
| 298 | } |
|
| 299 | ||
| 300 | return $app->redirect($app->url('cart')); |
|
| 301 | } |
|
| 302 | ||
| 303 | /** |
|
| 304 | * カートに入っている商品を削除する. |
|