| @@ 89-123 (lines=35) @@ | ||
| 86 | * @param Request $request |
|
| 87 | * @return array |
|
| 88 | */ |
|
| 89 | public function index(Application $app, Request $request) |
|
| 90 | { |
|
| 91 | // カートチェック |
|
| 92 | $response = $app->forward($app->path("shopping/checkToCart")); |
|
| 93 | if ($response->isRedirection() || $response->getContent()) { |
|
| 94 | return $response; |
|
| 95 | } |
|
| 96 | ||
| 97 | // 受注情報を初期化 |
|
| 98 | $response = $app->forward($app->path("shopping/initializeOrder")); |
|
| 99 | if ($response->isRedirection() || $response->getContent()) { |
|
| 100 | return $response; |
|
| 101 | } |
|
| 102 | ||
| 103 | // 単価集計し, フォームを生成する |
|
| 104 | $app->forwardChain($app->path("shopping/calculateOrder")) |
|
| 105 | ->forwardChain($app->path("shopping/createForm")); |
|
| 106 | ||
| 107 | // 受注のマイナスチェック |
|
| 108 | $response = $app->forward($app->path("shopping/checkToMinusPrice")); |
|
| 109 | if ($response->isRedirection() || $response->getContent()) { |
|
| 110 | return $response; |
|
| 111 | } |
|
| 112 | ||
| 113 | // 複数配送の場合、エラーメッセージを一度だけ表示 |
|
| 114 | $app->forward($app->path("shopping/handleMultipleErrors")); |
|
| 115 | ||
| 116 | $Order = $app['request_scope']->get('Order'); |
|
| 117 | $form = $app['request_scope']->get(OrderType::class); |
|
| 118 | ||
| 119 | return [ |
|
| 120 | 'form' => $form->createView(), |
|
| 121 | 'Order' => $Order |
|
| 122 | ]; |
|
| 123 | } |
|
| 124 | ||
| 125 | /** |
|
| 126 | * 購入確認画面から, 他の画面へのリダイレクト. |
|
| @@ 174-209 (lines=36) @@ | ||
| 171 | * @Method("POST") |
|
| 172 | * @Route("/shopping/confirm", name="shopping/confirm") |
|
| 173 | */ |
|
| 174 | public function confirm(Application $app, Request $request) |
|
| 175 | { |
|
| 176 | // カートチェック |
|
| 177 | $response = $app->forward($app->path("shopping/checkToCart")); |
|
| 178 | if ($response->isRedirection() || $response->getContent()) { |
|
| 179 | return $response; |
|
| 180 | } |
|
| 181 | ||
| 182 | // 受注の存在チェック |
|
| 183 | $response = $app->forward($app->path("shopping/existsOrder")); |
|
| 184 | if ($response->isRedirection() || $response->getContent()) { |
|
| 185 | return $response; |
|
| 186 | } |
|
| 187 | ||
| 188 | // form作成 |
|
| 189 | // FIXME イベントハンドラを外から渡したい |
|
| 190 | $app->forward($app->path("shopping/createForm")); |
|
| 191 | ||
| 192 | $form = $app['request_scope']->get(OrderType::class); |
|
| 193 | $Order = $app['request_scope']->get('Order'); |
|
| 194 | ||
| 195 | $form->handleRequest($request); |
|
| 196 | ||
| 197 | // 受注処理 |
|
| 198 | $response = $app->forward($app->path("shopping/completeOrder")); |
|
| 199 | if ($response->isRedirection() || $response->getContent()) { |
|
| 200 | return $response; |
|
| 201 | } |
|
| 202 | ||
| 203 | log_info('購入チェックエラー', array($Order->getId())); |
|
| 204 | ||
| 205 | return $app->render('Shopping/index.twig', array( |
|
| 206 | 'form' => $form->createView(), |
|
| 207 | 'Order' => $Order, |
|
| 208 | )); |
|
| 209 | } |
|
| 210 | ||
| 211 | ||
| 212 | /** |
|