Completed
Push — master ( 770316...74fc07 )
by Jeroen
09:08 queued 02:44
created

AbstractFormPageController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 29
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A serviceAction() 0 23 3
1
<?php
2
3
namespace Kunstmaan\FormBundle\Controller;
4
5
use Kunstmaan\NodeBundle\Helper\RenderContext;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
10
class AbstractFormPageController extends Controller
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...e\Controller\Controller has been deprecated with message: since Symfony 4.2, use "Symfony\Bundle\FrameworkBundle\Controller\AbstractController" instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
11
{
12
    /**
13
     * @param Request $request
14
     */
15
    public function serviceAction(Request $request)
16
    {
17
        $thanksParam = $request->get('thanks');
18
        $entity = $request->attributes->get('_entity');
19
        $context = array(
20
            'nodetranslation' => $request->attributes->get('_nodeTranslation'),
21
            'slug' => $request->attributes->get('url'),
22
            'page' => $entity,
23
            'resource' => $entity,
24
        );
25
26
        if (!empty($thanksParam)) {
27
            $context['thanks'] = true;
28
        }
29
30
        $renderContext = new RenderContext($context);
31
        $result = $this->container->get('kunstmaan_form.form_handler')->handleForm($entity, $request, $renderContext);
32
        if ($result instanceof Response) {
33
            return $result;
34
        }
35
36
        $request->attributes->set('_renderContext', $renderContext->getArrayCopy());
37
    }
38
}
39