Completed
Push — sf/improvement-coverage ( b3937e...01a837 )
by Kiyotaka
51:20 queued 45:08
created

SearchProductController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 24
rs 9.536
c 0
b 0
f 0
ccs 12
cts 12
cp 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Controller\Block;
15
16
use Eccube\Controller\AbstractController;
17
use Eccube\Event\EccubeEvents;
18
use Eccube\Event\EventArgs;
19
use Eccube\Form\Type\SearchProductBlockType;
20
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
21
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
22
use Symfony\Component\HttpFoundation\Request;
23
use Symfony\Component\HttpFoundation\RequestStack;
24
25
class SearchProductController extends AbstractController
26
{
27
    /**
28
     * @var RequestStack
29
     */
30
    protected $requestStack;
31
32 117
    public function __construct(RequestStack $requestStack
33
    ) {
34 117
        $this->requestStack = $requestStack;
35
    }
36
37
    /**
38
     * @Route("/block/search_product", name="block_search_product")
39
     * @Template("Block/search_product.twig")
40
     */
41 117
    public function index(Request $request)
42
    {
43 117
        $builder = $this->formFactory
44 117
            ->createNamedBuilder('', SearchProductBlockType::class)
45 117
            ->setMethod('GET');
46
47 117
        $event = new EventArgs(
48
            [
49 117
                'builder' => $builder,
50
            ],
51 117
            $request
52
        );
53
54 117
        $this->eventDispatcher->dispatch(EccubeEvents::FRONT_BLOCK_SEARCH_PRODUCT_INDEX_INITIALIZE, $event);
55
56 117
        $request = $this->requestStack->getMasterRequest();
57
58 117
        $form = $builder->getForm();
59 117
        $form->handleRequest($request);
60
61
        return [
62 117
            'form' => $form->createView(),
63
        ];
64
    }
65
}
66