<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Customize\Controller\Block;
use Eccube\Controller\AbstractController;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Form\Type\SearchProductBlockType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Annotation\Route;
class SideSearchController extends AbstractController
{
/**
* @var RequestStack
*/
protected $requestStack;
public function __construct(
RequestStack $requestStack
) {
$this->requestStack = $requestStack;
}
/**
* @Route("/block/side_serch", name="block_side_serch", methods={"GET"})
* @Template("Block/side_serch.twig")
*/
public function index(Request $request)
{
$builder = $this->formFactory
->createNamedBuilder('', SearchProductBlockType::class)
->setMethod('GET');
$event = new EventArgs(
[
'builder' => $builder,
],
$request
);
$this->eventDispatcher->dispatch($event, EccubeEvents::FRONT_BLOCK_SEARCH_PRODUCT_INDEX_INITIALIZE);
$request = $this->requestStack->getMainRequest();
$form = $builder->getForm();
$form->handleRequest($request);
return [
'form' => $form->createView(),
];
}
/**
* @Route("/block/side_serch_buy", name="block_side_serch_buy", methods={"GET"})
* @Template("Block/side_serch_buy.twig")
*/
public function index2(Request $request)
{
$builder = $this->formFactory
->createNamedBuilder('', SearchProductBlockType::class)
->setMethod('GET');
$event = new EventArgs(
[
'builder' => $builder,
],
$request
);
$this->eventDispatcher->dispatch($event, EccubeEvents::FRONT_BLOCK_SEARCH_PRODUCT_INDEX_INITIALIZE);
$request = $this->requestStack->getMainRequest();
$form = $builder->getForm();
$form->handleRequest($request);
return [
'form' => $form->createView(),
];
}
}