Code Duplication    Length = 35-36 lines in 3 locations

app/Plugin/ExamplePlugin/Controller/ExampleController.php 1 location

@@ 44-78 (lines=35) @@
41
     * @param Request $request
42
     * @return array
43
     */
44
    public function index(Application $app, Request $request)
45
    {
46
        // カートチェック
47
        $response = $app->forward($app->path("shopping/checkToCart"));
48
        if ($response->isRedirection() || $response->getContent()) {
49
            return $response;
50
        }
51
52
        // 受注情報を初期化
53
        $response = $app->forward($app->path("shopping/initializeOrder"));
54
        if ($response->isRedirection() || $response->getContent()) {
55
            return $response;
56
        }
57
58
        // 単価集計し, フォームを生成する
59
        $app->forwardChain($app->path("shopping/calculateOrder"))
60
            ->forwardChain($app->path("shopping/createForm"));
61
62
        // 受注のマイナスチェック
63
        $response = $app->forward($app->path("shopping/checkToMinusPrice"));
64
        if ($response->isRedirection() || $response->getContent()) {
65
            return $response;
66
        }
67
68
        // 複数配送の場合、エラーメッセージを一度だけ表示
69
        $app->forward($app->path("shopping/handleMultipleErrors"));
70
71
        $Order = $app['request_scope']->get('Order');
72
        $form = $app['request_scope']->get(OrderType::class);
73
74
        return [
75
            'form' => $form->createView(),
76
            'Order' => $Order
77
        ];
78
    }
79
80
    /**
81
     * 独自の決済処理.

src/Eccube/Controller/ShoppingController.php 2 locations

@@ 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
    /**