Skip to content

Commit

Permalink
ProductClassController の @component 対応
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Aug 21, 2017
1 parent 49dc8db commit 5b50af6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
26 changes: 20 additions & 6 deletions src/Eccube/Controller/Admin/Product/ProductClassController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManager;
use Eccube\Annotation\Inject;
use Eccube\Annotation\Component;
use Eccube\Application;
use Eccube\Common\Constant;
use Eccube\Entity\ClassName;
Expand All @@ -43,6 +44,9 @@
use Eccube\Repository\ProductClassRepository;
use Eccube\Repository\ProductRepository;
use Eccube\Repository\TaxRuleRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
Expand All @@ -54,6 +58,10 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Validator\Constraints as Assert;

/**
* @Component
* @Route(service=ProductClassController::class)
*/
class ProductClassController
{
/**
Expand Down Expand Up @@ -118,6 +126,9 @@ class ProductClassController

/**
* 商品規格が登録されていなければ新規登録、登録されていれば更新画面を表示する
*
* @Route("/{_admin}/product/product/class/{id}", requirements={"id" = "\d+"}, name="admin_product_product_class")
* @Template("Product/product_class.twig")
*/
public function index(Application $app, Request $request, $id)
{
Expand Down Expand Up @@ -231,14 +242,14 @@ public function index(Application $app, Request $request, $id)
}
}

return $app->render('Product/product_class.twig', array(
return [
'form' => $form->createView(),
'classForm' => $productClassForm,
'Product' => $Product,
'not_product_class' => true,
'error' => null,
'has_class_category_flg' => $hasClassCategoryFlg,
));
];
} else {
// 既に商品規格が登録されている場合、商品規格画面を表示する

Expand Down Expand Up @@ -320,21 +331,24 @@ public function index(Application $app, Request $request, $id)

$productClassForm = $builder->getForm()->createView();

return $app->render('Product/product_class.twig', array(
return [
'classForm' => $productClassForm,
'Product' => $Product,
'class_name1' => $ClassName1,
'class_name2' => $ClassName2,
'not_product_class' => false,
'error' => null,
'has_class_category_flg' => true,
));
];
}
}

/**
* 商品規格の登録、更新、削除を行う
*
* @Route("/{_admin}/product/product/class/edit/{id}", requirements={"id" = "\d+"}, name="admin_product_product_class_edit")
* @Template("Product/product_class.twig")
*
* @param Application $app
* @param Request $request
* @param int $id
Expand Down Expand Up @@ -638,7 +652,7 @@ protected function render($app, $Product, $ProductClass, $not_product_class, $cl
log_info('商品規格登録エラー');


return $app->render('Product/product_class.twig', array(
return [
'form' => $form->createView(),
'classForm' => $classForm->createView(),
'Product' => $Product,
Expand All @@ -647,7 +661,7 @@ protected function render($app, $Product, $ProductClass, $not_product_class, $cl
'not_product_class' => $not_product_class,
'error' => $error,
'has_class_category_flg' => true,
));
];
}


Expand Down
3 changes: 0 additions & 3 deletions src/Eccube/ControllerProvider/AdminControllerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ public function connect(Application $app)
}

// product
$c->match('/product/product/class/{id}', '\Eccube\Controller\Admin\Product\ProductClassController::index')->assert('id', '\d+')->bind('admin_product_product_class');

$c->post('/product/product/class/edit/{id}', '\Eccube\Controller\Admin\Product\ProductClassController::edit')->assert('id', '\d+')->bind('admin_product_product_class_edit');

$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');
Expand Down

0 comments on commit 5b50af6

Please sign in to comment.