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

ErrorPageController::showAction()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 28
rs 8.8571
cc 1
eloc 16
nc 1
nop 1
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
Bug introduced by
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(),
0 ignored issues
show
Bug introduced by
The method getLayout cannot be called on $page->getTemplate() (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
54
            $parameters
55
        );
56
57
        return $response;
58
    }
59
}
60