diff --git a/src/Eccube/Controller/Admin/Product/CategoryController.php b/src/Eccube/Controller/Admin/Product/CategoryController.php index 616de709813..3ef5c95d7e9 100644 --- a/src/Eccube/Controller/Admin/Product/CategoryController.php +++ b/src/Eccube/Controller/Admin/Product/CategoryController.php @@ -25,6 +25,7 @@ namespace Eccube\Controller\Admin\Product; use Doctrine\ORM\EntityManager; +use Eccube\Annotation\Component; use Eccube\Annotation\Inject; use Eccube\Application; use Eccube\Controller\AbstractController; @@ -34,6 +35,9 @@ use Eccube\Form\Type\Admin\CategoryType; use Eccube\Repository\CategoryRepository; use Eccube\Service\CsvExportService; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Form\FormFactory; use Symfony\Component\HttpFoundation\Request; @@ -41,6 +45,10 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +/** + * @Component + * @Route(service=CategoryController::class) + */ class CategoryController extends AbstractController { /** @@ -79,6 +87,12 @@ class CategoryController extends AbstractController */ protected $categoryRepository; + /** + * @Route("/{_admin}/product/category", name="admin_product_category") + * @Route("/{_admin}/product/category/{parent_id}", requirements={"parent_id" = "\d+"}, name="admin_product_category_show") + * @Route("/{_admin}/product/category/{id}/edit", requirements={"id" = "\d+"}, name="admin_product_category_edit") + * @Template("Product/category.twig") + */ public function index(Application $app, Request $request, $parent_id = null, $id = null) { if ($parent_id) { @@ -164,15 +178,19 @@ public function index(Application $app, Request $request, $parent_id = null, $id // ツリー表示のため、ルートからのカテゴリを取得 $TopCategories = $this->categoryRepository->getList(null); - return $app->render('Product/category.twig', array( + return [ 'form' => $form->createView(), 'Parent' => $Parent, 'Categories' => $Categories, 'TopCategories' => $TopCategories, 'TargetCategory' => $TargetCategory, - )); + ]; } + /** + * @Method("DELETE") + * @Route("/{_admin}/product/category/{id}/delete", requirements={"id" = "\d+"}, name="admin_product_category_delete") + */ public function delete(Application $app, Request $request, $id) { $this->isTokenValid($app); @@ -214,6 +232,10 @@ public function delete(Application $app, Request $request, $id) } } + /** + * @Method("POST") + * @Route("/{_admin}/product/category/rank/move", name="admin_product_category_rank_move") + */ public function moveRank(Application $app, Request $request) { if ($request->isXmlHttpRequest()) { @@ -234,6 +256,8 @@ public function moveRank(Application $app, Request $request) /** * カテゴリCSVの出力. * + * @Route("/{_admin}/product/category/export", name="admin_product_category_export") + * * @param Application $app * @param Request $request * @return StreamedResponse diff --git a/src/Eccube/ControllerProvider/AdminControllerProvider.php b/src/Eccube/ControllerProvider/AdminControllerProvider.php index bcb76077037..e6db77d6b82 100644 --- a/src/Eccube/ControllerProvider/AdminControllerProvider.php +++ b/src/Eccube/ControllerProvider/AdminControllerProvider.php @@ -41,13 +41,6 @@ public function connect(Application $app) // product - $c->match('/product/category', '\Eccube\Controller\Admin\Product\CategoryController::index')->bind('admin_product_category'); - $c->match('/product/category/export', '\Eccube\Controller\Admin\Product\CategoryController::export')->bind('admin_product_category_export'); - $c->match('/product/category/{parent_id}', '\Eccube\Controller\Admin\Product\CategoryController::index')->assert('parent_id', '\d+')->bind('admin_product_category_show'); - $c->match('/product/category/{id}/edit', '\Eccube\Controller\Admin\Product\CategoryController::index')->assert('id', '\d+')->bind('admin_product_category_edit'); - $c->delete('/product/category/{id}/delete', '\Eccube\Controller\Admin\Product\CategoryController::delete')->assert('id', '\d+')->bind('admin_product_category_delete'); - $c->post('/product/category/rank/move', '\Eccube\Controller\Admin\Product\CategoryController::moveRank')->bind('admin_product_category_rank_move'); - $c->match('/product/class_name', '\Eccube\Controller\Admin\Product\ClassNameController::index')->bind('admin_product_class_name'); $c->match('/product/class_name/{id}/edit', '\Eccube\Controller\Admin\Product\ClassNameController::index')->assert('id', '\d+')->bind('admin_product_class_name_edit'); $c->delete('/product/class_name/{id}/delete', '\Eccube\Controller\Admin\Product\ClassNameController::delete')->assert('id', '\d+')->bind('admin_product_class_name_delete');