Completed
Pull Request — master (#90)
by Arnaud
05:26
created

ListResponder::respond()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 17
ccs 0
cts 6
cp 0
rs 9.4285
cc 2
eloc 11
nc 2
nop 4
crap 6
1
<?php
2
3
namespace LAG\AdminBundle\Action\Responder;
4
5
use LAG\AdminBundle\Action\Configuration\ActionConfiguration;
6
use LAG\AdminBundle\Admin\AdminInterface;
7
use Symfony\Component\Form\FormInterface;
8
use Symfony\Component\HttpFoundation\Response;
9
use Twig_Environment;
10
11
class ListResponder implements ResponderInterface
12
{
13
    use ResponderTrait;
14
    
15
    /**
16
     * ListResponder constructor.
17
     *
18
     * @param Twig_Environment  $twig
19
     */
20
    public function __construct(Twig_Environment $twig)
21
    {
22
        $this->twig = $twig;
23
    }
24
    
25
    /**
26
     * @param ActionConfiguration $configuration
27
     * @param AdminInterface      $admin
28
     * @param FormInterface       $form
29
     * @param FormInterface       $filterForm
30
     *
31
     * @return Response
32
     *
33
     */
34
    public function respond(
35
        ActionConfiguration $configuration,
36
        AdminInterface $admin,
37
        FormInterface $form,
38
        FormInterface $filterForm = null
39
    ) {
40
        $context = [
41
            'admin' => $admin,
42
            'form' => $form->createView(),
43
        ];
44
    
45
        if (null !== $filterForm) {
46
            $context['filterForm'] = $filterForm->createView();
47
        }
48
    
49
        return $this->render($configuration->getParameter('template'), $context);
50
    }
51
}
52