Completed
Pull Request — master (#433)
by Paul
06:40
created

TwigBundle/Controller/ErrorPageController.php (1 issue)

Labels
Severity

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 Victoire\Bundle\TwigBundle\Controller;
4
5
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
use Victoire\Bundle\TwigBundle\Entity\ErrorPage;
11
use Victoire\Bundle\ViewReferenceBundle\ViewReference\ViewReference;
12
13
/**
14
 * Show an error page.
15
 *
16
 * @param Request $request The request
17
 * @param string  $code    The error page code
18
 *
19
 * @Route("/error", name="victoire_error_show")
20
 */
21
class ErrorPageController extends Controller
22
{
23
    /**
24
     * Show an error page.
25
     *
26
     * @Route("/{code}", name="victoire_errorPage_show")
27
     * @ParamConverter("page", class="VictoireTwigBundle:ErrorPage")
28
     *
29
     * @return Response
30
     */
31
    public function showAction(ErrorPage $page)
32
    {
33
        //add the view to twig
34
        $this->container->get('twig')->addGlobal('view', $page);
35
        $page->setReference(new ViewReference($page->getId()));
36
37
        $parameters = [
38
            'view'   => $page,
39
            'id'     => $page->getId(),
40
            'locale' => $page->getLocale(),
0 ignored issues
show
The method getLocale() does not seem to exist on object<Victoire\Bundle\T...undle\Entity\ErrorPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
        ];
42
43
        $this->get('victoire_widget_map.builder')->build($page);
44
        $this->get('victoire_widget_map.widget_data_warmer')->warm(
45
            $this->get('doctrine.orm.entity_manager'),
46
            $page
47
        );
48
49
        $this->container->get('victoire_core.current_view')->setCurrentView($page);
50
51
        //create the response
52
        $response = $this->container->get('templating')->renderResponse(
53
            'VictoireCoreBundle:Layout:'.$page->getTemplate()->getLayout(),
54
            $parameters
55
        );
56
57
        return $response;
58
    }
59
}
60