| @@ 178-209 (lines=32) @@ | ||
| 175 | * @Route("/shopping/redirect", name="shopping_redirect_to") |
|
| 176 | * @Template("Shopping/index.twig") |
|
| 177 | */ |
|
| 178 | public function redirectTo(Application $app, Request $request) |
|
| 179 | { |
|
| 180 | // カートチェック |
|
| 181 | $response = $app->forward($app->path("shopping_check_to_cart")); |
|
| 182 | if ($response->isRedirection() || $response->getContent()) { |
|
| 183 | return $response; |
|
| 184 | } |
|
| 185 | ||
| 186 | // 受注の存在チェック |
|
| 187 | $response = $app->forward($app->path("shopping_exists_order")); |
|
| 188 | if ($response->isRedirection() || $response->getContent()) { |
|
| 189 | return $response; |
|
| 190 | } |
|
| 191 | ||
| 192 | // フォームの生成 |
|
| 193 | $app->forward($app->path("shopping_create_form")); |
|
| 194 | $form = $this->parameterBag->get(OrderType::class); |
|
| 195 | $form->handleRequest($request); |
|
| 196 | ||
| 197 | // 各種変更ページへリダイレクトする |
|
| 198 | $response = $app->forward($app->path("shopping_redirect_to_change")); |
|
| 199 | if ($response->isRedirection() || $response->getContent()) { |
|
| 200 | return $response; |
|
| 201 | } |
|
| 202 | $form = $this->parameterBag->get(OrderType::class); |
|
| 203 | $Order = $this->parameterBag->get('Order'); |
|
| 204 | ||
| 205 | return [ |
|
| 206 | 'form' => $form->createView(), |
|
| 207 | 'Order' => $Order, |
|
| 208 | ]; |
|
| 209 | } |
|
| 210 | ||
| 211 | /** |
|
| 212 | * 購入処理 |
|
| @@ 218-249 (lines=32) @@ | ||
| 215 | * @Method("POST") |
|
| 216 | * @Template("Shopping/confirm.twig") |
|
| 217 | */ |
|
| 218 | public function confirm(Application $app, Request $request) |
|
| 219 | { |
|
| 220 | // カートチェック |
|
| 221 | $response = $app->forward($app->path("shopping_check_to_cart")); |
|
| 222 | if ($response->isRedirection() || $response->getContent()) { |
|
| 223 | return $response; |
|
| 224 | } |
|
| 225 | ||
| 226 | // 受注の存在チェック |
|
| 227 | $response = $app->forward($app->path("shopping_exists_order")); |
|
| 228 | if ($response->isRedirection() || $response->getContent()) { |
|
| 229 | return $response; |
|
| 230 | } |
|
| 231 | ||
| 232 | // フォームの生成 |
|
| 233 | $app->forward($app->path("shopping_create_form")); |
|
| 234 | $form = $this->parameterBag->get(OrderType::class); |
|
| 235 | $form->handleRequest($request); |
|
| 236 | ||
| 237 | $form = $this->parameterBag->get(OrderType::class); |
|
| 238 | $Order = $this->parameterBag->get('Order'); |
|
| 239 | ||
| 240 | $flowResult = $this->executePurchaseFlow($app, $Order); |
|
| 241 | if ($flowResult->hasWarning() || $flowResult->hasError()) { |
|
| 242 | return $app->redirect($app->url('shopping_error')); |
|
| 243 | } |
|
| 244 | ||
| 245 | return [ |
|
| 246 | 'form' => $form->createView(), |
|
| 247 | 'Order' => $Order, |
|
| 248 | ]; |
|
| 249 | } |
|
| 250 | ||
| 251 | /** |
|
| 252 | * 購入処理 |
|
| @@ 258-293 (lines=36) @@ | ||
| 255 | * @Method("POST") |
|
| 256 | * @Template("Shopping/index.twig") |
|
| 257 | */ |
|
| 258 | public function order(Application $app, Request $request) |
|
| 259 | { |
|
| 260 | // カートチェック |
|
| 261 | $response = $app->forward($app->path("shopping_check_to_cart")); |
|
| 262 | if ($response->isRedirection() || $response->getContent()) { |
|
| 263 | return $response; |
|
| 264 | } |
|
| 265 | ||
| 266 | // 受注の存在チェック |
|
| 267 | $response = $app->forward($app->path("shopping_exists_order")); |
|
| 268 | if ($response->isRedirection() || $response->getContent()) { |
|
| 269 | return $response; |
|
| 270 | } |
|
| 271 | ||
| 272 | // form作成 |
|
| 273 | // FIXME イベントハンドラを外から渡したい |
|
| 274 | $app->forward($app->path("shopping_create_form")); |
|
| 275 | ||
| 276 | $form = $this->parameterBag->get(OrderType::class); |
|
| 277 | $Order = $this->parameterBag->get('Order'); |
|
| 278 | ||
| 279 | $form->handleRequest($request); |
|
| 280 | ||
| 281 | // 受注処理 |
|
| 282 | $response = $app->forward($app->path("shopping_complete_order")); |
|
| 283 | if ($response->isRedirection() || $response->getContent()) { |
|
| 284 | return $response; |
|
| 285 | } |
|
| 286 | ||
| 287 | log_info('購入チェックエラー', array($Order->getId())); |
|
| 288 | ||
| 289 | return [ |
|
| 290 | 'form' => $form->createView(), |
|
| 291 | 'Order' => $Order, |
|
| 292 | ]; |
|
| 293 | } |
|
| 294 | ||
| 295 | ||
| 296 | /** |
|