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

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. class SearchProductController extends AbstractController
  22. {
  23.     /**
  24.      * @var RequestStack
  25.      */
  26.     protected $requestStack;
  27.     public function __construct(RequestStack $requestStack
  28.     ) {
  29.         $this->requestStack $requestStack;
  30.     }
  31.     /**
  32.      * @Route("/block/search_product", name="block_search_product", methods={"GET"})
  33.      * @Route("/block/search_product_sp", name="block_search_product_sp", methods={"GET"})
  34.      * @Template("Block/search_product.twig")
  35.      */
  36.     public function index(Request $request)
  37.     {
  38.         $builder $this->formFactory
  39.             ->createNamedBuilder(''SearchProductBlockType::class)
  40.             ->setMethod('GET');
  41.         $event = new EventArgs(
  42.             [
  43.                 'builder' => $builder,
  44.             ],
  45.             $request
  46.         );
  47.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_BLOCK_SEARCH_PRODUCT_INDEX_INITIALIZE);
  48.         $request $this->requestStack->getMainRequest();
  49.         $form $builder->getForm();
  50.         $form->handleRequest($request);
  51.         return [
  52.             'form' => $form->createView(),
  53.         ];
  54.     }
  55. }