Passed
Push — master ( b4cb9f...51bac7 )
by Anthony
02:22
created

RenderPageController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderPageAction() 0 12 2
1
<?php
2
3
namespace PiouPiou\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();
21
		
22
		if ($page) {
23
			return $this->render("@RibsAdmin/page.html.twig", ["page" => $page, "navigation" => $navigation]);
24
		}
25
		
26
		throw new NotFoundHttpException("The required page does not exist");
27
	}
28
}
29