src/Eccube/Controller/Block/SearchProductController.php line 54

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Controller\Block;
  13. use Eccube\Controller\AbstractController;
  14. use Eccube\Event\EccubeEvents;
  15. use Eccube\Event\EventArgs;
  16. use Eccube\Form\Type\SearchProductBlockType;
  17. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\HttpFoundation\RequestStack;
  20. use Symfony\Component\Routing\Annotation\Route;
  21. use Eccube\Repository\CategoryRepository;
  22. class SearchProductController extends AbstractController
  23. {
  24.     /**
  25.      * @var RequestStack
  26.      */
  27.     protected $requestStack;
  28.     /**
  29.      * @var CategoryRepository
  30.      */
  31.     protected $categoryRepository;
  32.     /**
  33.      * SearchProductController constructor.
  34.      *
  35.      * @param CategoryRepository $categoryRepository
  36.      */
  37.     public function __construct(RequestStack $requestStackCategoryRepository $categoryRepository) {
  38.         $this->requestStack $requestStack;
  39.         $this->categoryRepository $categoryRepository;
  40.     }
  41.     /**
  42.      * @Route("/block/search_product", name="block_search_product", methods={"GET"})
  43.      * @Route("/block/search_product_sp", name="block_search_product_sp", methods={"GET"})
  44.      * @Template("Block/search_product.twig")
  45.      */
  46.     public function index(Request $request)
  47.     {
  48.         $routeName $request->attributes->get('_route');
  49.         $builder $this->formFactory
  50.             ->createNamedBuilder(''SearchProductBlockType::class)
  51.             ->setMethod('GET');
  52.         $event = new EventArgs(
  53.             [
  54.                 'builder' => $builder,
  55.             ],
  56.             $request
  57.         );
  58.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_BLOCK_SEARCH_PRODUCT_INDEX_INITIALIZE);
  59.         $request $this->requestStack->getMainRequest();
  60.         $form $builder->getForm();
  61.         $form->handleRequest($request);
  62.         $Categories $this->categoryRepository->getList();
  63.         return [
  64.             'form' => $form->createView(),
  65.             'routeName' => $routeName,
  66.             'Categories' => $Categories,
  67.         ];
  68.     }
  69. }