Completed
Pull Request — master (#90)
by Arnaud
03:14
created

DeleteResponder::respond()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 9
cts 9
cp 1
rs 9.3142
c 0
b 0
f 0
cc 3
eloc 13
nc 2
nop 3
crap 3
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\RedirectResponse;
9
use Symfony\Component\HttpFoundation\Response;
10
11
class DeleteResponder extends AbstractResponder
12
{
13
    /**
14
     * @param ActionConfiguration $configuration
15
     * @param AdminInterface      $admin
16
     * @param FormInterface       $form
17
     *
18
     * @return Response
19
     */
20 2
    public function respond(
21
        ActionConfiguration $configuration,
22
        AdminInterface $admin,
23
        FormInterface $form
24
    ) {
25 2
        $template = $configuration->getParameter('template');
26
        
27 2
        if ($form->isSubmitted() && $form->isValid()) {
28
            $url = $this
29 1
                ->router
30 1
                ->generate($admin->generateRouteName('list'))
31
            ;
32
33 1
            return new RedirectResponse($url);
34
        }
35
        
36 1
        return $this->render($template, [
37 1
            'admin' => $admin,
38 1
            'form' => $form->createView(),
39
        ]);
40
    }
41
}
42