Skip to content

Commit

Permalink
CategoryController の @component 対応
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Aug 22, 2017
1 parent 5b50af6 commit 6b68632
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
28 changes: 26 additions & 2 deletions src/Eccube/Controller/Admin/Product/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,13 +35,20 @@
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;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
* @Component
* @Route(service=CategoryController::class)
*/
class CategoryController extends AbstractController
{
/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand All @@ -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
Expand Down
7 changes: 0 additions & 7 deletions src/Eccube/ControllerProvider/AdminControllerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 6b68632

Please sign in to comment.