Completed
Push — master ( a7fff6...5ea170 )
by Jeroen
18:57 queued 10s
created

Controller/AbstractFormPageController.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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