@@ -19,140 +19,140 @@ |
||
19 | 19 | |
20 | 20 | class PackageController extends AbstractController |
21 | 21 | { |
22 | - /** |
|
23 | - * @Route("/packages/", name="ribsadmin_packages") |
|
24 | - * @param EntityManagerInterface $em |
|
25 | - * @return Response |
|
26 | - */ |
|
27 | - public function index(EntityManagerInterface $em): Response |
|
28 | - { |
|
29 | - $packages = $em->getRepository(Package::class)->findAll(); |
|
22 | + /** |
|
23 | + * @Route("/packages/", name="ribsadmin_packages") |
|
24 | + * @param EntityManagerInterface $em |
|
25 | + * @return Response |
|
26 | + */ |
|
27 | + public function index(EntityManagerInterface $em): Response |
|
28 | + { |
|
29 | + $packages = $em->getRepository(Package::class)->findAll(); |
|
30 | 30 | |
31 | - return $this->render("@RibsAdmin/packages/list.html.twig", ["packages" => $packages]); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * @Route("/packages/create/", name="ribsadmin_packages_create") |
|
36 | - * @Route("/packages/show/{guid}", name="ribsadmin_packages_show") |
|
37 | - * @Route("/packages/edit/{guid}", name="ribsadmin_packages_edit") |
|
38 | - * @param Request $request |
|
39 | - * @param EntityManagerInterface $em |
|
40 | - * @param PackagistApi $packagist |
|
41 | - * @param string|null $guid |
|
42 | - * @return Response |
|
43 | - * @throws ClientExceptionInterface |
|
44 | - * @throws RedirectionExceptionInterface |
|
45 | - * @throws ServerExceptionInterface |
|
46 | - * @throws TransportExceptionInterface |
|
47 | - */ |
|
48 | - public function edit(Request $request, EntityManagerInterface $em, PackagistApi $packagist, string $guid = null): Response |
|
49 | - { |
|
50 | - $disabled_form = strpos($request->get("_route"), "_show") ? true : false; |
|
51 | - if (!$guid) { |
|
52 | - $package = new Package(); |
|
53 | - $text = "created"; |
|
54 | - } else { |
|
55 | - $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
56 | - $text = "edited"; |
|
57 | - } |
|
58 | - |
|
59 | - $form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Package::class, $package, ["disabled" => $disabled_form]); |
|
60 | - $form->handleRequest($request); |
|
61 | - |
|
62 | - if ($form->isSubmitted() && $form->isValid()) { |
|
63 | - /** @var Package $data */ |
|
64 | - $data = $form->getData(); |
|
65 | - $em->persist($data); |
|
66 | - $em->flush(); |
|
67 | - $this->addFlash("success-flash", "Package " . $data->getProjectName() . " was " . $text); |
|
68 | - |
|
69 | - return $this->redirectToRoute("ribsadmin_packages"); |
|
70 | - } |
|
71 | - |
|
72 | - return $this->render("@RibsAdmin/packages/edit.html.twig", [ |
|
73 | - "disabled_form" => $disabled_form, |
|
74 | - "form" => $form->createView(), |
|
75 | - "form_errors" => $form->getErrors(), |
|
76 | - "package" => $package, |
|
77 | - "versions" => $packagist->getAllPackagistVersions($package->getPackageName()) |
|
78 | - ]); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @Route("/packages/delete/{guid}", name="ribsadmin_packages_delete") |
|
83 | - * @param EntityManagerInterface $em |
|
84 | - * @param string $guid |
|
85 | - * @return RedirectResponse |
|
86 | - */ |
|
87 | - public function delete(EntityManagerInterface $em, string $guid): RedirectResponse |
|
88 | - { |
|
89 | - $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
90 | - |
|
91 | - if ($package) { |
|
92 | - $em->remove($package); |
|
93 | - $em->flush(); |
|
94 | - $this->addFlash("success-flash", "The project package was deleted"); |
|
95 | - } else { |
|
96 | - $this->addFlash("error-flash", "The project package was not found"); |
|
97 | - } |
|
98 | - |
|
99 | - return $this->redirectToRoute("ribsadmin_packages"); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @Route("/packages/update/{guid}", name="ribsadmin_packages_update") |
|
104 | - * @param Version $version |
|
105 | - * @param string $guid |
|
106 | - * @return RedirectResponse |
|
107 | - * @throws ClientExceptionInterface |
|
108 | - * @throws RedirectionExceptionInterface |
|
109 | - * @throws ServerExceptionInterface |
|
110 | - * @throws TransportExceptionInterface |
|
111 | - */ |
|
112 | - public function updatePackage(Version $version, string $guid): RedirectResponse |
|
113 | - { |
|
114 | - if ($guid) { |
|
115 | - $version->save($guid); |
|
116 | - |
|
117 | - if ($version->getMessages()) { |
|
118 | - $message = "<ul>"; |
|
119 | - $message .= "<li>The project package was not well updated</li>"; |
|
120 | - foreach ($version->getMessages() as $version_message) { |
|
121 | - $message .= "<li>".$version_message."</li>"; |
|
122 | - } |
|
123 | - $message .= "</ul>"; |
|
124 | - |
|
125 | - $this->addFlash("info-flash", $message); |
|
126 | - } else { |
|
127 | - $this->addFlash("success-flash", "The project package was updated"); |
|
128 | - } |
|
129 | - } else { |
|
130 | - $this->addFlash("error-flash", "The project package was not found"); |
|
131 | - } |
|
132 | - |
|
133 | - return $this->redirectToRoute("ribsadmin_packages"); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @Route("/packages/update-version/{guid}/{install_version}", name="ribsadmin_packages_update_version") |
|
138 | - * @param Version $version |
|
139 | - * @param string $guid |
|
140 | - * @param string $install_version |
|
141 | - * @return RedirectResponse|Response |
|
142 | - * @throws ClientExceptionInterface |
|
143 | - * @throws RedirectionExceptionInterface |
|
144 | - * @throws ServerExceptionInterface |
|
145 | - * @throws TransportExceptionInterface |
|
146 | - */ |
|
147 | - public function changePackageVersion(Version $version, string $guid, string $install_version) |
|
148 | - { |
|
149 | - $response = $version->updatePackage($guid, $install_version); |
|
150 | - |
|
151 | - if ($response) { |
|
152 | - $response = str_replace("\n", "<br>", $response); |
|
153 | - return $this->render("@RibsAdmin/packages/show-update-version.html.twig", ["logs" => $response]); |
|
154 | - } |
|
155 | - |
|
156 | - return $this->redirectToRoute("ribsadmin_packages_update", ["guid" => $guid]); |
|
157 | - } |
|
31 | + return $this->render("@RibsAdmin/packages/list.html.twig", ["packages" => $packages]); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * @Route("/packages/create/", name="ribsadmin_packages_create") |
|
36 | + * @Route("/packages/show/{guid}", name="ribsadmin_packages_show") |
|
37 | + * @Route("/packages/edit/{guid}", name="ribsadmin_packages_edit") |
|
38 | + * @param Request $request |
|
39 | + * @param EntityManagerInterface $em |
|
40 | + * @param PackagistApi $packagist |
|
41 | + * @param string|null $guid |
|
42 | + * @return Response |
|
43 | + * @throws ClientExceptionInterface |
|
44 | + * @throws RedirectionExceptionInterface |
|
45 | + * @throws ServerExceptionInterface |
|
46 | + * @throws TransportExceptionInterface |
|
47 | + */ |
|
48 | + public function edit(Request $request, EntityManagerInterface $em, PackagistApi $packagist, string $guid = null): Response |
|
49 | + { |
|
50 | + $disabled_form = strpos($request->get("_route"), "_show") ? true : false; |
|
51 | + if (!$guid) { |
|
52 | + $package = new Package(); |
|
53 | + $text = "created"; |
|
54 | + } else { |
|
55 | + $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
56 | + $text = "edited"; |
|
57 | + } |
|
58 | + |
|
59 | + $form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Package::class, $package, ["disabled" => $disabled_form]); |
|
60 | + $form->handleRequest($request); |
|
61 | + |
|
62 | + if ($form->isSubmitted() && $form->isValid()) { |
|
63 | + /** @var Package $data */ |
|
64 | + $data = $form->getData(); |
|
65 | + $em->persist($data); |
|
66 | + $em->flush(); |
|
67 | + $this->addFlash("success-flash", "Package " . $data->getProjectName() . " was " . $text); |
|
68 | + |
|
69 | + return $this->redirectToRoute("ribsadmin_packages"); |
|
70 | + } |
|
71 | + |
|
72 | + return $this->render("@RibsAdmin/packages/edit.html.twig", [ |
|
73 | + "disabled_form" => $disabled_form, |
|
74 | + "form" => $form->createView(), |
|
75 | + "form_errors" => $form->getErrors(), |
|
76 | + "package" => $package, |
|
77 | + "versions" => $packagist->getAllPackagistVersions($package->getPackageName()) |
|
78 | + ]); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @Route("/packages/delete/{guid}", name="ribsadmin_packages_delete") |
|
83 | + * @param EntityManagerInterface $em |
|
84 | + * @param string $guid |
|
85 | + * @return RedirectResponse |
|
86 | + */ |
|
87 | + public function delete(EntityManagerInterface $em, string $guid): RedirectResponse |
|
88 | + { |
|
89 | + $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
90 | + |
|
91 | + if ($package) { |
|
92 | + $em->remove($package); |
|
93 | + $em->flush(); |
|
94 | + $this->addFlash("success-flash", "The project package was deleted"); |
|
95 | + } else { |
|
96 | + $this->addFlash("error-flash", "The project package was not found"); |
|
97 | + } |
|
98 | + |
|
99 | + return $this->redirectToRoute("ribsadmin_packages"); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @Route("/packages/update/{guid}", name="ribsadmin_packages_update") |
|
104 | + * @param Version $version |
|
105 | + * @param string $guid |
|
106 | + * @return RedirectResponse |
|
107 | + * @throws ClientExceptionInterface |
|
108 | + * @throws RedirectionExceptionInterface |
|
109 | + * @throws ServerExceptionInterface |
|
110 | + * @throws TransportExceptionInterface |
|
111 | + */ |
|
112 | + public function updatePackage(Version $version, string $guid): RedirectResponse |
|
113 | + { |
|
114 | + if ($guid) { |
|
115 | + $version->save($guid); |
|
116 | + |
|
117 | + if ($version->getMessages()) { |
|
118 | + $message = "<ul>"; |
|
119 | + $message .= "<li>The project package was not well updated</li>"; |
|
120 | + foreach ($version->getMessages() as $version_message) { |
|
121 | + $message .= "<li>".$version_message."</li>"; |
|
122 | + } |
|
123 | + $message .= "</ul>"; |
|
124 | + |
|
125 | + $this->addFlash("info-flash", $message); |
|
126 | + } else { |
|
127 | + $this->addFlash("success-flash", "The project package was updated"); |
|
128 | + } |
|
129 | + } else { |
|
130 | + $this->addFlash("error-flash", "The project package was not found"); |
|
131 | + } |
|
132 | + |
|
133 | + return $this->redirectToRoute("ribsadmin_packages"); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @Route("/packages/update-version/{guid}/{install_version}", name="ribsadmin_packages_update_version") |
|
138 | + * @param Version $version |
|
139 | + * @param string $guid |
|
140 | + * @param string $install_version |
|
141 | + * @return RedirectResponse|Response |
|
142 | + * @throws ClientExceptionInterface |
|
143 | + * @throws RedirectionExceptionInterface |
|
144 | + * @throws ServerExceptionInterface |
|
145 | + * @throws TransportExceptionInterface |
|
146 | + */ |
|
147 | + public function changePackageVersion(Version $version, string $guid, string $install_version) |
|
148 | + { |
|
149 | + $response = $version->updatePackage($guid, $install_version); |
|
150 | + |
|
151 | + if ($response) { |
|
152 | + $response = str_replace("\n", "<br>", $response); |
|
153 | + return $this->render("@RibsAdmin/packages/show-update-version.html.twig", ["logs" => $response]); |
|
154 | + } |
|
155 | + |
|
156 | + return $this->redirectToRoute("ribsadmin_packages_update", ["guid" => $guid]); |
|
157 | + } |
|
158 | 158 | } |
@@ -9,50 +9,50 @@ |
||
9 | 9 | |
10 | 10 | class ExceptionListener |
11 | 11 | { |
12 | - /** |
|
13 | - * @var ParameterBagInterface |
|
14 | - */ |
|
15 | - private $paramter; |
|
16 | - |
|
17 | - /** |
|
18 | - * @var User |
|
19 | - */ |
|
20 | - private $user; |
|
21 | - |
|
22 | - public function __construct(ParameterBagInterface $parameterBag, TokenStorageInterface $tokenStorage) |
|
23 | - { |
|
24 | - $this->paramter = $parameterBag; |
|
25 | - if ($tokenStorage->getToken() && is_object($tokenStorage->getToken()->getUser()) && $tokenStorage->getToken()->getUser()->getUser()) { |
|
26 | - $this->user = $tokenStorage->getToken()->getUser()->getUser(); |
|
27 | - } |
|
28 | - } |
|
29 | - |
|
30 | - public function onKernelException(ExceptionEvent $event) |
|
31 | - { |
|
32 | - $slack_webhook = $this->paramter->get('ribs_admin.slack_webhook'); |
|
33 | - if ($slack_webhook) { |
|
34 | - $data = array(); |
|
35 | - $data['channel'] = '#errors'; |
|
36 | - $data['username'] = $_SERVER['HTTP_HOST']; |
|
37 | - $data['text'] = "• *Erreur* : " . strip_tags($event->getThrowable()->getMessage()); |
|
38 | - $data['text'] .= "\n• *Erreur File* : " . strip_tags($event->getThrowable()->getFile()) . " at line :" . strip_tags($event->getThrowable()->getLine()); |
|
39 | - $data['text'] .= "\n• *URL* : " . $event->getRequest()->getUri(); |
|
40 | - |
|
41 | - if ($this->user) { |
|
42 | - $data['text'] .= "\n• *Utilisateur* : " . $this->user . " with id : " . $this->user->getId(); |
|
43 | - } |
|
44 | - |
|
45 | - $data['unfurl_links'] = false; |
|
46 | - $data_json = json_encode($data); |
|
47 | - |
|
48 | - $ch = curl_init(); |
|
49 | - curl_setopt($ch, CURLOPT_URL, $slack_webhook); |
|
50 | - curl_setopt($ch, CURLOPT_POST, 1); |
|
51 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json))); |
|
52 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json); |
|
53 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
54 | - curl_exec($ch); |
|
55 | - curl_close($ch); |
|
56 | - } |
|
57 | - } |
|
12 | + /** |
|
13 | + * @var ParameterBagInterface |
|
14 | + */ |
|
15 | + private $paramter; |
|
16 | + |
|
17 | + /** |
|
18 | + * @var User |
|
19 | + */ |
|
20 | + private $user; |
|
21 | + |
|
22 | + public function __construct(ParameterBagInterface $parameterBag, TokenStorageInterface $tokenStorage) |
|
23 | + { |
|
24 | + $this->paramter = $parameterBag; |
|
25 | + if ($tokenStorage->getToken() && is_object($tokenStorage->getToken()->getUser()) && $tokenStorage->getToken()->getUser()->getUser()) { |
|
26 | + $this->user = $tokenStorage->getToken()->getUser()->getUser(); |
|
27 | + } |
|
28 | + } |
|
29 | + |
|
30 | + public function onKernelException(ExceptionEvent $event) |
|
31 | + { |
|
32 | + $slack_webhook = $this->paramter->get('ribs_admin.slack_webhook'); |
|
33 | + if ($slack_webhook) { |
|
34 | + $data = array(); |
|
35 | + $data['channel'] = '#errors'; |
|
36 | + $data['username'] = $_SERVER['HTTP_HOST']; |
|
37 | + $data['text'] = "• *Erreur* : " . strip_tags($event->getThrowable()->getMessage()); |
|
38 | + $data['text'] .= "\n• *Erreur File* : " . strip_tags($event->getThrowable()->getFile()) . " at line :" . strip_tags($event->getThrowable()->getLine()); |
|
39 | + $data['text'] .= "\n• *URL* : " . $event->getRequest()->getUri(); |
|
40 | + |
|
41 | + if ($this->user) { |
|
42 | + $data['text'] .= "\n• *Utilisateur* : " . $this->user . " with id : " . $this->user->getId(); |
|
43 | + } |
|
44 | + |
|
45 | + $data['unfurl_links'] = false; |
|
46 | + $data_json = json_encode($data); |
|
47 | + |
|
48 | + $ch = curl_init(); |
|
49 | + curl_setopt($ch, CURLOPT_URL, $slack_webhook); |
|
50 | + curl_setopt($ch, CURLOPT_POST, 1); |
|
51 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json))); |
|
52 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json); |
|
53 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
54 | + curl_exec($ch); |
|
55 | + curl_close($ch); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | } |
59 | 59 | \ No newline at end of file |
@@ -7,43 +7,43 @@ |
||
7 | 7 | |
8 | 8 | class CreateUpdateAwareListener |
9 | 9 | { |
10 | - /** |
|
11 | - * @var User |
|
12 | - */ |
|
13 | - private $user; |
|
10 | + /** |
|
11 | + * @var User |
|
12 | + */ |
|
13 | + private $user; |
|
14 | 14 | |
15 | - /** |
|
16 | - * CreateUpdateAwareListener constructor. |
|
17 | - * @param TokenStorageInterface $tokenStorage |
|
18 | - */ |
|
19 | - public function __construct(TokenStorageInterface $tokenStorage) |
|
20 | - { |
|
21 | - if ($tokenStorage->getToken() && is_object($tokenStorage->getToken()->getUser()) && $tokenStorage->getToken()->getUser()->getUser()) { |
|
22 | - $this->user = $tokenStorage->getToken()->getUser()->getUser(); |
|
23 | - } else { |
|
24 | - $this->user = null; |
|
25 | - } |
|
26 | - } |
|
15 | + /** |
|
16 | + * CreateUpdateAwareListener constructor. |
|
17 | + * @param TokenStorageInterface $tokenStorage |
|
18 | + */ |
|
19 | + public function __construct(TokenStorageInterface $tokenStorage) |
|
20 | + { |
|
21 | + if ($tokenStorage->getToken() && is_object($tokenStorage->getToken()->getUser()) && $tokenStorage->getToken()->getUser()->getUser()) { |
|
22 | + $this->user = $tokenStorage->getToken()->getUser()->getUser(); |
|
23 | + } else { |
|
24 | + $this->user = null; |
|
25 | + } |
|
26 | + } |
|
27 | 27 | |
28 | - public function prePersist($entity) |
|
29 | - { |
|
30 | - if ($this->user) { |
|
31 | - if ($entity->getCreatedBy() === null) { |
|
32 | - $entity->setCreatedAt(new \DateTime()); |
|
33 | - $entity->setCreatedBy($this->user); |
|
34 | - } |
|
35 | - if ($entity->getUpdatedBy() === null) { |
|
36 | - $entity->setUpdatedAt(new \DateTime()); |
|
37 | - $entity->setUpdatedBy($this->user); |
|
38 | - } |
|
39 | - } |
|
40 | - } |
|
28 | + public function prePersist($entity) |
|
29 | + { |
|
30 | + if ($this->user) { |
|
31 | + if ($entity->getCreatedBy() === null) { |
|
32 | + $entity->setCreatedAt(new \DateTime()); |
|
33 | + $entity->setCreatedBy($this->user); |
|
34 | + } |
|
35 | + if ($entity->getUpdatedBy() === null) { |
|
36 | + $entity->setUpdatedAt(new \DateTime()); |
|
37 | + $entity->setUpdatedBy($this->user); |
|
38 | + } |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - public function preUpdate($entity) |
|
43 | - { |
|
44 | - if ($this->user) { |
|
45 | - $entity->setUpdatedAt(new \DateTime()); |
|
46 | - $entity->setUpdatedBy($this->user); |
|
47 | - } |
|
48 | - } |
|
42 | + public function preUpdate($entity) |
|
43 | + { |
|
44 | + if ($this->user) { |
|
45 | + $entity->setUpdatedAt(new \DateTime()); |
|
46 | + $entity->setUpdatedBy($this->user); |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
@@ -10,49 +10,49 @@ |
||
10 | 10 | |
11 | 11 | class NavigationBuilderController extends AbstractController |
12 | 12 | { |
13 | - private $nav = []; |
|
14 | - |
|
15 | - /** |
|
16 | - * function that display the left navigation mapped by user rights |
|
17 | - * @param Globals $globals |
|
18 | - * @param AccessRights $access_rights |
|
19 | - * @return Response |
|
20 | - */ |
|
21 | - public function getLeftNavigation(Globals $globals, AccessRights $access_rights): Response |
|
22 | - { |
|
23 | - $navigation = json_decode(file_get_contents($globals->getBaseBundlePath() . "/Resources/json/navigation.json"), true); |
|
24 | - |
|
25 | - foreach ($navigation["items"] as $item) { |
|
26 | - if ($access_rights->testRight($item["right"]) && (!isset($item["position"]) || $item["position"] === "left")) { |
|
27 | - $this->nav[] = $item; |
|
28 | - } |
|
29 | - } |
|
30 | - |
|
31 | - $this->getModuleNavigation($access_rights); |
|
32 | - |
|
33 | - return $this->render("@RibsAdmin/navigation.html.twig", ["navigation" => $this->nav]); |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * to get all modules navigation and test right navigation |
|
38 | - * @param AccessRights $access_rights |
|
39 | - */ |
|
40 | - private function getModuleNavigation(AccessRights $access_rights) |
|
41 | - { |
|
42 | - $modules = $this->getDoctrine()->getRepository(Module::class)->findBy([ |
|
43 | - "active" => true, |
|
44 | - "displayed" => true |
|
45 | - ]); |
|
46 | - |
|
47 | - foreach ($modules as $module) { |
|
48 | - $navigation = json_decode(file_get_contents($this->get("ribs_admin.globals")->getBaseBundlePath |
|
49 | - ($module->getPackageName(), $module->getDevMode()) . "/Resources/json/navigation.json"), true); |
|
50 | - |
|
51 | - foreach ($navigation["items"] as $item) { |
|
52 | - if ($access_rights->testRight($item["right"]) && (!isset($item["position"]) || $item["position"] === "left")) { |
|
53 | - $this->nav[] = $item; |
|
54 | - } |
|
55 | - } |
|
56 | - } |
|
57 | - } |
|
13 | + private $nav = []; |
|
14 | + |
|
15 | + /** |
|
16 | + * function that display the left navigation mapped by user rights |
|
17 | + * @param Globals $globals |
|
18 | + * @param AccessRights $access_rights |
|
19 | + * @return Response |
|
20 | + */ |
|
21 | + public function getLeftNavigation(Globals $globals, AccessRights $access_rights): Response |
|
22 | + { |
|
23 | + $navigation = json_decode(file_get_contents($globals->getBaseBundlePath() . "/Resources/json/navigation.json"), true); |
|
24 | + |
|
25 | + foreach ($navigation["items"] as $item) { |
|
26 | + if ($access_rights->testRight($item["right"]) && (!isset($item["position"]) || $item["position"] === "left")) { |
|
27 | + $this->nav[] = $item; |
|
28 | + } |
|
29 | + } |
|
30 | + |
|
31 | + $this->getModuleNavigation($access_rights); |
|
32 | + |
|
33 | + return $this->render("@RibsAdmin/navigation.html.twig", ["navigation" => $this->nav]); |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * to get all modules navigation and test right navigation |
|
38 | + * @param AccessRights $access_rights |
|
39 | + */ |
|
40 | + private function getModuleNavigation(AccessRights $access_rights) |
|
41 | + { |
|
42 | + $modules = $this->getDoctrine()->getRepository(Module::class)->findBy([ |
|
43 | + "active" => true, |
|
44 | + "displayed" => true |
|
45 | + ]); |
|
46 | + |
|
47 | + foreach ($modules as $module) { |
|
48 | + $navigation = json_decode(file_get_contents($this->get("ribs_admin.globals")->getBaseBundlePath |
|
49 | + ($module->getPackageName(), $module->getDevMode()) . "/Resources/json/navigation.json"), true); |
|
50 | + |
|
51 | + foreach ($navigation["items"] as $item) { |
|
52 | + if ($access_rights->testRight($item["right"]) && (!isset($item["position"]) || $item["position"] === "left")) { |
|
53 | + $this->nav[] = $item; |
|
54 | + } |
|
55 | + } |
|
56 | + } |
|
57 | + } |
|
58 | 58 | } |