RenderPageController::renderPage()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 10
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
6
use Symfony\Component\Routing\Annotation\Route;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9
10
class RenderPageController extends AbstractController
11
{
12
    /**
13
     * @Route("/page/{url}", name="page", requirements={"url" = "[a-zA-Z0-9\-\_\/]*"})
14
     * @param string $url
15
     * @return Response
16
     */
17
    public function renderPage(string $url): Response
18
    {
19
        $em = $this->getDoctrine()->getManager();
20
21
        $page = $em->getRepository("RibsAdminBundle:Page")->findOneBy(["url" => $url]);
22
        $navigation = $em->getRepository("RibsAdminBundle:Navigation")->findAllNavigation();
0 ignored issues
show
Bug introduced by
The method findAllNavigation() does not exist on Doctrine\Persistence\ObjectRepository. Did you maybe mean findAll()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        $navigation = $em->getRepository("RibsAdminBundle:Navigation")->/** @scrutinizer ignore-call */ findAllNavigation();

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...
23
24
        if ($page) {
25
            return $this->render("@RibsAdmin/page.html.twig", ["page" => $page, "navigation" => $navigation]);
26
        }
27
28
        throw new NotFoundHttpException("The required page does not exist");
29
    }
30
}
31