@@ -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 | } |
@@ -45,8 +45,7 @@ |
||
| 45 | 45 | ]); |
| 46 | 46 | |
| 47 | 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); |
|
| 48 | + $navigation = json_decode(file_get_contents($this->get("ribs_admin.globals")->getBaseBundlePath($module->getPackageName(), $module->getDevMode()) . "/Resources/json/navigation.json"), true); |
|
| 50 | 49 | |
| 51 | 50 | foreach ($navigation["items"] as $item) { |
| 52 | 51 | if ($access_rights->testRight($item["right"]) && (!isset($item["position"]) || $item["position"] === "left")) { |