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

SearchProductController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
ccs 14
cts 14
cp 1
wmc 2
lcom 1
cbo 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 24 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