Passed
Push — master ( 3519d2...fb2019 )
by Anthony
02:42
created

RenderPageController::renderPageAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Ribs\RibsAdminBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9
10
class RenderPageController extends Controller
11
{
12
	/**
13
	 * @Route("/page/{url}", name="page", requirements={"url" = "[a-zA-Z0-9\-\_\/]*"})
14
	 */
15
	public function renderPageAction(string $url): Response
16
	{
17
		$em = $this->getDoctrine()->getManager();
18
		
19
		$page = $em->getRepository("RibsAdminBundle:Page")->findOneBy(["url" => $url]);
20
		$navigation = $em->getRepository("RibsAdminBundle:Navigation")->findAllNavigation();
0 ignored issues
show
Unused Code introduced by
The assignment to $navigation is dead and can be removed.
Loading history...
21
		
22
		if ($page) {
23
			return $this->render("@RibsAdmin/page.html.twig", ["page" => $page]);
24
		}
25
		
26
		throw new NotFoundHttpException("The required page does not exist");
27
	}
28
}
29