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

NavigationBuilderController   A

Complexity

Total Complexity 3

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 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getLeftNavigationAction() 0 12 3
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\HttpFoundation\Response;
7
8
class NavigationBuilderController extends Controller
9
{
10
	/**
11
	 * @return Response function that display the left navigation mapped by user rights
12
	 */
13
	public function getLeftNavigationAction(): Response
14
	{
15
		$navigation = json_decode(file_get_contents($this->get("ribs_admin.globals")->getBaseBundlePath() . "/Resources/json/navigation.json"), true);
16
		$menu = [];
17
		
18
		foreach ($navigation["items"] as $item) {
19
			if ($this->get("ribs_admin.acess_rights")->testRight($item["right"])) {
20
				$menu[] = $item;
21
			}
22
		}
23
		
24
		return $this->render("@RibsAdmin/navigation.html.twig", ["navigation" => $menu]);
25
	}
26
}