Passed
Push — master ( a4aad6...b9f8cf )
by Anthony
02:39
created

NavigationBuilderController::getLeftNavigation()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 2
dl 0
loc 13
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Controller;
4
5
use PiouPiou\RibsAdminBundle\Entity\Module;
6
use PiouPiou\RibsAdminBundle\Service\AccessRights;
7
use PiouPiou\RibsAdminBundle\Service\Globals;
8
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
9
use Symfony\Component\HttpFoundation\Response;
10
11
class NavigationBuilderController extends AbstractController
12
{
13
	private  $nav = [];
14
	
15
	/**
16
     * function that display the left navigation mapped by user rights
17
	 * @return Response
18
	 */
19
	public function getLeftNavigation(Globals $globals, AccessRights $access_rights): Response
20
	{
21
		$navigation = json_decode(file_get_contents($globals->getBaseBundlePath() . "/Resources/json/navigation.json"), true);
22
		
23
		foreach ($navigation["items"] as $item) {
24
			if ($access_rights->testRight($item["right"])) {
25
				$this->nav[] = $item;
26
			}
27
		}
28
		
29
		$this->getModuleNavigation();
30
		
31
		return $this->render("@RibsAdmin/navigation.html.twig", ["navigation" => $this->nav]);
32
	}
33
	
34
	/**
35
	 * to get all modules navigation and test right navigation
36
	 */
37
	private function getModuleNavigation()
38
	{
39
		$modules = $this->getDoctrine()->getRepository(Module::class)->findBy([
40
			"active" => true,
41
			"displayed" => true
42
		]);
43
		
44
		foreach ($modules as $module) {
45
			$navigation = json_decode(file_get_contents($this->get("ribs_admin.globals")->getBaseBundlePath
0 ignored issues
show
Bug introduced by
The method get() does not exist on PiouPiou\RibsAdminBundle...gationBuilderController. ( Ignorable by Annotation )

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

45
			$navigation = json_decode(file_get_contents($this->/** @scrutinizer ignore-call */ get("ribs_admin.globals")->getBaseBundlePath

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...
46
				($module->getPackageName()) . "/Resources/json/navigation.json"), true);
47
			
48
			foreach ($navigation["items"] as $item) {
49
				if ($this->get("ribs_admin.acess_rights")->testRight($item["right"])) {
50
					$this->nav[] = $item;
51
				}
52
			}
53
		}
54
	}
55
}
56