Code Duplication    Length = 16-20 lines in 4 locations

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

@@ 249-267 (lines=19) @@
246
    /**
247
     * @Route("/%eccube_admin_route%/product/class_category/sort_no/move", name="admin_product_class_category_sort_no_move", methods={"POST"})
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
                $ClassCategory = $this->classCategoryRepository
259
                    ->find($categoryId);
260
                $ClassCategory->setSortNo($sortNo);
261
                $this->entityManager->persist($ClassCategory);
262
            }
263
            $this->entityManager->flush();
264
265
            return new Response('Successful');
266
        }
267
    }
268
}
269

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

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

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

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

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

@@ 272-291 (lines=20) @@
269
     *
270
     * @return Response
271
     */
272
    public function moveSortNo(Request $request)
273
    {
274
        if (!$request->isXmlHttpRequest()) {
275
            throw new BadRequestHttpException();
276
        }
277
278
        if ($this->isTokenValid()) {
279
            $sortNos = $request->request->all();
280
            foreach ($sortNos as $paymentId => $sortNo) {
281
                /** @var Payment $Payment */
282
                $Payment = $this->paymentRepository
283
                    ->find($paymentId);
284
                $Payment->setSortNo($sortNo);
285
                $this->entityManager->persist($Payment);
286
            }
287
            $this->entityManager->flush();
288
289
            return new Response();
290
        }
291
    }
292
}
293