Completed
Push — master ( 1f36be...d8b059 )
by Beñat
03:59
created

PageTemplateFormAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A action() 0 11 1
1
<?php
2
3
/*
4
 * This file is part of the CMS Kernel library.
5
 *
6
 * Copyright (c) 2016 LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LIN3S\CMSKernel\Infrastructure\Web\Symfony\Action;
13
14
use App\Infrastructure\Web\Symfony\Form\Type\TemplateType;
15
use Symfony\Component\Form\Extension\Core\Type\FormType;
16
use Symfony\Component\Form\FormFactoryInterface;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\Templating\EngineInterface;
19
20
class PageTemplateFormAction
21
{
22
    private $templating;
23
    private $factory;
24
25
    public function __construct(FormFactoryInterface $factory, EngineInterface $templating)
26
    {
27
        $this->templating = $templating;
28
        $this->factory = $factory;
29
    }
30
31
    public function action($template)
32
    {
33
        $form = $this->factory->createNamedBuilder('', FormType::class, null, ['csrf_protection' => false])->getForm();
34
        $form = TemplateType::buildForm($form, $template);
35
36
        return new Response(
37
            $this->templating->render('template_form.html.twig', [
38
                'form' => $form->createView(),
39
            ])
40
        );
41
    }
42
}
43