Code Duplication    Length = 24-28 lines in 3 locations

src/Eccube/Controller/Admin/Content/NewsController.php 1 location

@@ 160-187 (lines=28) @@
157
     *
158
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
159
     */
160
    public function delete(Request $request, News $News, CacheUtil $cacheUtil)
161
    {
162
        $this->isTokenValid();
163
164
        log_info('新着情報削除開始', [$News->getId()]);
165
166
        try {
167
            $this->newsRepository->delete($News);
168
169
            $event = new EventArgs(['News' => $News], $request);
170
            $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_CONTENT_NEWS_DELETE_COMPLETE, $event);
171
172
            $this->addSuccess('admin.common.delete_complete', 'admin');
173
174
            log_info('新着情報削除完了', [$News->getId()]);
175
176
            // キャッシュの削除
177
            $cacheUtil->clearDoctrineCache();
178
        } catch (\Exception $e) {
179
            $message = trans('admin.common.delete_error_foreign_key', ['%name%' => $News->getTitle()]);
180
            $this->addError($message, 'admin');
181
182
            log_error('新着情報削除エラー', [$News->getId(), $e]);
183
        }
184
185
        return $this->redirectToRoute('admin_content_news');
186
    }
187
}
188

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

@@ 140-163 (lines=24) @@
137
    /**
138
     * @Route("/%eccube_admin_route%/product/class_name/{id}/delete", requirements={"id" = "\d+"}, name="admin_product_class_name_delete", methods={"DELETE"})
139
     */
140
    public function delete(Request $request, ClassName $ClassName)
141
    {
142
        $this->isTokenValid();
143
144
        log_info('商品規格削除開始', [$ClassName->getId()]);
145
146
        try {
147
            $this->classNameRepository->delete($ClassName);
148
149
            $event = new EventArgs(['ClassName' => $ClassName], $request);
150
            $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_PRODUCT_CLASS_NAME_DELETE_COMPLETE, $event);
151
152
            $this->addSuccess('admin.common.delete_complete', 'admin');
153
154
            log_info('商品規格削除完了', [$ClassName->getId()]);
155
        } catch (\Exception $e) {
156
            $message = trans('admin.common.delete_error_foreign_key', ['%name%' => $ClassName->getName()]);
157
            $this->addError($message, 'admin');
158
159
            log_error('商品規格削除エラー', [$ClassName->getId(), $e]);
160
        }
161
162
        return $this->redirectToRoute('admin_product_class_name');
163
    }
164
165
    /**
166
     * @Route("/%eccube_admin_route%/product/class_name/sort_no/move", name="admin_product_class_name_sort_no_move", methods={"POST"})

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

@@ 129-156 (lines=28) @@
126
    /**
127
     * @Route("/%eccube_admin_route%/product/tag/{id}/delete", requirements={"id" = "\d+"}, name="admin_product_tag_delete", methods={"DELETE"})
128
     */
129
    public function delete(Request $request, Tag $Tag)
130
    {
131
        $this->isTokenValid();
132
133
        log_info('タグ削除開始', [$Tag->getId()]);
134
135
        try {
136
            $this->tagRepository->delete($Tag);
137
138
            $event = new EventArgs(
139
                [
140
                    'Tag' => $Tag,
141
                ], $request
142
            );
143
            $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_PRODUCT_TAG_DELETE_COMPLETE, $event);
144
145
            $this->addSuccess('admin.common.delete_complete', 'admin');
146
147
            log_info('タグ削除完了', [$Tag->getId()]);
148
        } catch (\Exception $e) {
149
            log_info('タグ削除エラー', [$Tag->getId(), $e]);
150
151
            $message = trans('admin.common.delete_error.foreign_key', ['%name%' => $Tag->getName()]);
152
            $this->addError($message, 'admin');
153
        }
154
155
        return $this->redirectToRoute('admin_product_tag');
156
    }
157
158
    /**
159
     * @Route("/%eccube_admin_route%/product/tag/sort_no/move", name="admin_product_tag_sort_no_move", methods={"POST"})