Code Duplication    Length = 15-20 lines in 6 locations

src/Eccube/Controller/Admin/Product/ClassCategoryController.php 1 location

@@ 258-272 (lines=15) @@
255
     * @Method("POST")
256
     * @Route("/product/class_category/sort_no/move", name="admin_product_class_category_sort_no_move")
257
     */
258
    public function moveSortNo(Request $request)
259
    {
260
        if ($request->isXmlHttpRequest()) {
261
            $sortNos = $request->request->all();
262
            foreach ($sortNos as $categoryId => $sortNo) {
263
                $ClassCategory = $this->classCategoryRepository
264
                    ->find($categoryId);
265
                $ClassCategory->setSortNo($sortNo);
266
                $this->entityManager->persist($ClassCategory);
267
            }
268
            $this->entityManager->flush();
269
        }
270
271
        return new Response('Successful');
272
    }
273
}
274

src/Eccube/Controller/Admin/Product/ClassNameController.php 1 location

@@ 170-184 (lines=15) @@
167
     * @Method("POST")
168
     * @Route("/%eccube_admin_route%/product/class_name/sort_no/move", name="admin_product_class_name_sort_no_move")
169
     */
170
    public function moveSortNo(Request $request)
171
    {
172
        if ($request->isXmlHttpRequest()) {
173
            $sortNos = $request->request->all();
174
            foreach ($sortNos as $classNameId => $sortNo) {
175
                $ClassName = $this->classNameRepository
176
                    ->find($classNameId);
177
                $ClassName->setSortNo($sortNo);
178
                $this->entityManager->persist($ClassName);
179
            }
180
            $this->entityManager->flush();
181
        }
182
183
        return new Response();
184
    }
185
}
186

src/Eccube/Controller/Admin/Product/TagController.php 1 location

@@ 165-180 (lines=16) @@
162
     * @Method("POST")
163
     * @Route("/%eccube_admin_route%/product/tag/sort_no/move", name="admin_product_tag_sort_no_move")
164
     */
165
    public function moveSortNo(Request $request)
166
    {
167
        if ($request->isXmlHttpRequest() && $this->isTokenValid()) {
168
            $sortNos = $request->request->all();
169
            foreach ($sortNos as $tagId => $sortNo) {
170
                /* @var $Tag \Eccube\Entity\Tag */
171
                $Tag = $this->tagRepository
172
                    ->find($tagId);
173
                $Tag->setSortNo($sortNo);
174
                $this->entityManager->persist($Tag);
175
            }
176
            $this->entityManager->flush();
177
        }
178
179
        return new Response();
180
    }
181
182
    protected function dispatchComplete(Request $request, FormInterface $form, Tag $Tag)
183
    {

src/Eccube/Controller/Admin/Product/CategoryController.php 1 location

@@ 249-268 (lines=20) @@
246
     * @Method("POST")
247
     * @Route("/%eccube_admin_route%/product/category/sort_no/move", name="admin_product_category_sort_no_move")
248
     */
249
    public function moveSortNo(Request $request)
250
    {
251
        if (!$request->isXmlHttpRequest()) {
252
            throw new BadRequestHttpException();
253
        }
254
255
        if ($this->isTokenValid()) {
256
            $sortNos = $request->request->all();
257
            foreach ($sortNos as $categoryId => $sortNo) {
258
                /* @var $Category \Eccube\Entity\Category */
259
                $Category = $this->categoryRepository
260
                    ->find($categoryId);
261
                $Category->setSortNo($sortNo);
262
                $this->entityManager->persist($Category);
263
            }
264
            $this->entityManager->flush();
265
266
            return new Response('Successful');
267
        }
268
    }
269
270
    /**
271
     * カテゴリCSVの出力.

src/Eccube/Controller/Admin/Setting/Shop/PaymentController.php 1 location

@@ 318-334 (lines=17) @@
315
     *
316
     * @return Response
317
     */
318
    public function moveSortNo(Request $request)
319
    {
320
        if ($request->isXmlHttpRequest()) {
321
            $this->isTokenValid();
322
            $sortNos = $request->request->all();
323
            foreach ($sortNos as $paymentId => $sortNo) {
324
                /** @var Payment $Payment */
325
                $Payment = $this->paymentRepository
326
                    ->find($paymentId);
327
                $Payment->setSortNo($sortNo);
328
                $this->entityManager->persist($Payment);
329
            }
330
            $this->entityManager->flush();
331
        }
332
333
        return new Response();
334
    }
335
}
336

src/Eccube/Controller/Admin/Setting/Shop/DeliveryController.php 1 location

@@ 346-363 (lines=18) @@
343
     * @Method("POST")
344
     * @Route("/%eccube_admin_route%/setting/shop/delivery/sort_no/move", name="admin_setting_shop_delivery_sort_no_move")
345
     */
346
    public function moveSortNo(Request $request)
347
    {
348
        if (!$request->isXmlHttpRequest()) {
349
            throw new BadRequestHttpException();
350
        }
351
352
        if ($this->isTokenValid()) {
353
            $sortNos = $request->request->all();
354
            foreach ($sortNos as $deliveryId => $sortNo) {
355
                $Delivery = $this->deliveryRepository->find($deliveryId);
356
                $Delivery->setSortNo($sortNo);
357
                $this->entityManager->persist($Delivery);
358
            }
359
            $this->entityManager->flush();
360
        }
361
362
        return $this->json('OK', 200);
363
    }
364
}
365