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

AbstractFormPageController::serviceAction()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 20
cp 0
rs 9.552
c 0
b 0
f 0
cc 3
nc 4
nop 1
crap 12
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