@@ -13,7 +13,7 @@ |
||
13 | 13 | private $nav = []; |
14 | 14 | |
15 | 15 | /** |
16 | - * function that display the left navigation mapped by user rights |
|
16 | + * function that display the left navigation mapped by user rights |
|
17 | 17 | * @return Response |
18 | 18 | */ |
19 | 19 | public function getLeftNavigation(Globals $globals, AccessRights $access_rights): Response |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | /** @var TokenStorageInterface */ |
51 | 51 | private $token_storage; |
52 | 52 | |
53 | - /** |
|
54 | - * AccessRights constructor. |
|
55 | - * @param ContainerInterface $container |
|
56 | - * @param RouterInterface $router |
|
57 | - * @param SessionInterface $session |
|
58 | - * @param RequestStack $request |
|
59 | - * @param TokenStorageInterface $tokenStorage |
|
60 | - * @param Globals $globals |
|
61 | - * @param ModuleService $module |
|
62 | - */ |
|
53 | + /** |
|
54 | + * AccessRights constructor. |
|
55 | + * @param ContainerInterface $container |
|
56 | + * @param RouterInterface $router |
|
57 | + * @param SessionInterface $session |
|
58 | + * @param RequestStack $request |
|
59 | + * @param TokenStorageInterface $tokenStorage |
|
60 | + * @param Globals $globals |
|
61 | + * @param ModuleService $module |
|
62 | + */ |
|
63 | 63 | public function __construct(ContainerInterface $container, RouterInterface $router, SessionInterface $session, RequestStack $request, TokenStorageInterface $tokenStorage, Globals $globals, ModuleService $module) |
64 | 64 | { |
65 | 65 | $this->container = $container; |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | $this->module = $module; |
71 | 71 | $this->token_storage = $tokenStorage; |
72 | 72 | if ($this->token_storage->getToken() && is_object($this->token_storage->getToken()->getUser()) && $this->token_storage->getToken()->getUser()->getUser()) { |
73 | - $this->user = $this->token_storage->getToken()->getUser()->getUser(); |
|
74 | - } |
|
73 | + $this->user = $this->token_storage->getToken()->getUser()->getUser(); |
|
74 | + } |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | public function onKernelController() |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | - * function that allow to test a right directly in the view |
|
118 | + * function that allow to test a right directly in the view |
|
119 | 119 | * @param string $right |
120 | 120 | * @return bool |
121 | 121 | */ |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | |
127 | 127 | $all_rights = array_merge($user_rights, $list_rights); |
128 | 128 | |
129 | - if (in_array("*", $all_rights)) { |
|
130 | - return true; |
|
131 | - } |
|
129 | + if (in_array("*", $all_rights)) { |
|
130 | + return true; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | if (in_array($right, $all_rights)) { |
134 | 134 | return true; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | - * test if route_right is found in users rights |
|
141 | + * test if route_right is found in users rights |
|
142 | 142 | * @param array $route_right |
143 | 143 | * @return bool |
144 | 144 | */ |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | $all_rights = array_merge($user_rights, $list_rights); |
151 | 151 | |
152 | 152 | if (in_array("*", $all_rights)) { |
153 | - return true; |
|
154 | - } |
|
153 | + return true; |
|
154 | + } |
|
155 | 155 | |
156 | 156 | foreach ($all_rights as $right) { |
157 | 157 | if (in_array($right, $route_right)) { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | - * function that search if the right contain an url or more |
|
166 | + * function that search if the right contain an url or more |
|
167 | 167 | * @param $needle |
168 | 168 | * @param $haystack |
169 | 169 | * @return bool|mixed |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | - * function that retun a array that contain all user rights or empty array if no right found |
|
190 | + * function that retun a array that contain all user rights or empty array if no right found |
|
191 | 191 | * @return array |
192 | 192 | */ |
193 | 193 | private function getUserRights(): array |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | - * function that retun a array that contain all rights of rattached list right of the current user |
|
205 | + * function that retun a array that contain all rights of rattached list right of the current user |
|
206 | 206 | * @return array |
207 | 207 | */ |
208 | 208 | private function getRightsListOfUser(): array |
@@ -28,15 +28,15 @@ |
||
28 | 28 | ]); |
29 | 29 | } |
30 | 30 | |
31 | - /** |
|
32 | - * @Route("/access-rights-management/create/", name="ribsadmin_access_rights_create") |
|
33 | - * @Route("/access-rights-management/edit/{guid}", name="ribsadmin_access_rights_edit") |
|
34 | - * @param Request $request |
|
35 | - * @param Globals $globals |
|
36 | - * @param ModuleService $module |
|
37 | - * @param string|null $guid |
|
38 | - * @return Response |
|
39 | - */ |
|
31 | + /** |
|
32 | + * @Route("/access-rights-management/create/", name="ribsadmin_access_rights_create") |
|
33 | + * @Route("/access-rights-management/edit/{guid}", name="ribsadmin_access_rights_edit") |
|
34 | + * @param Request $request |
|
35 | + * @param Globals $globals |
|
36 | + * @param ModuleService $module |
|
37 | + * @param string|null $guid |
|
38 | + * @return Response |
|
39 | + */ |
|
40 | 40 | public function editAction(Request $request, Globals $globals, ModuleService $module, string $guid = null): Response |
41 | 41 | { |
42 | 42 | $em = $this->getDoctrine()->getManager(); |
@@ -11,17 +11,17 @@ |
||
11 | 11 | |
12 | 12 | class LoginController extends AbstractController |
13 | 13 | { |
14 | - /** |
|
15 | - * @Route("/login/", name="ribsadmin_login") |
|
16 | - * @param CsrfTokenManagerInterface $token |
|
17 | - * @param AuthenticationUtils $auth_utils |
|
18 | - * @return Response |
|
19 | - */ |
|
14 | + /** |
|
15 | + * @Route("/login/", name="ribsadmin_login") |
|
16 | + * @param CsrfTokenManagerInterface $token |
|
17 | + * @param AuthenticationUtils $auth_utils |
|
18 | + * @return Response |
|
19 | + */ |
|
20 | 20 | public function loginAction(AuthenticationUtils $auth_utils): Response |
21 | 21 | { |
22 | - $csrf_token = $this->has('security.csrf.token_manager') |
|
23 | - ? $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue() |
|
24 | - : null; |
|
22 | + $csrf_token = $this->has('security.csrf.token_manager') |
|
23 | + ? $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue() |
|
24 | + : null; |
|
25 | 25 | |
26 | 26 | if ($auth_utils->getLastAuthenticationError()) { |
27 | 27 | $this->addFlash("error-flash", "Your login or password are incorrect"); |
@@ -7,8 +7,8 @@ |
||
7 | 7 | |
8 | 8 | class RibsAdminBundle extends Bundle |
9 | 9 | { |
10 | - public function getContainerExtension() |
|
11 | - { |
|
12 | - return new RibsAdminExtension(); |
|
13 | - } |
|
10 | + public function getContainerExtension() |
|
11 | + { |
|
12 | + return new RibsAdminExtension(); |
|
13 | + } |
|
14 | 14 | } |
@@ -10,12 +10,12 @@ |
||
10 | 10 | |
11 | 11 | class RibsAdminExtension extends Extension |
12 | 12 | { |
13 | - public function load(array $configs, ContainerBuilder $container) |
|
14 | - { |
|
15 | - $loader = new YamlFileLoader( |
|
16 | - $container, |
|
17 | - new FileLocator(__DIR__.'/../Resources/config') |
|
18 | - ); |
|
19 | - $loader->load('services.yml'); |
|
20 | - } |
|
13 | + public function load(array $configs, ContainerBuilder $container) |
|
14 | + { |
|
15 | + $loader = new YamlFileLoader( |
|
16 | + $container, |
|
17 | + new FileLocator(__DIR__.'/../Resources/config') |
|
18 | + ); |
|
19 | + $loader->load('services.yml'); |
|
20 | + } |
|
21 | 21 | } |
@@ -26,22 +26,22 @@ discard block |
||
26 | 26 | "label" => "Package name", |
27 | 27 | "required" => true |
28 | 28 | ]) |
29 | - ->add("titleTag", TextType::class, [ |
|
30 | - "label" => "Title tag", |
|
31 | - "required" => true |
|
32 | - ]) |
|
33 | - ->add("descriptionTag", TextareaType::class, [ |
|
34 | - "label" => "Description tag", |
|
35 | - "required" => true, |
|
36 | - ]) |
|
37 | - ->add("url", TextType::class, [ |
|
38 | - "label" => "Url", |
|
39 | - "required" => true |
|
40 | - ]) |
|
41 | - ->add("urlAdmin", TextType::class, [ |
|
42 | - "label" => "Admin url", |
|
43 | - "required" => true |
|
44 | - ]) |
|
29 | + ->add("titleTag", TextType::class, [ |
|
30 | + "label" => "Title tag", |
|
31 | + "required" => true |
|
32 | + ]) |
|
33 | + ->add("descriptionTag", TextareaType::class, [ |
|
34 | + "label" => "Description tag", |
|
35 | + "required" => true, |
|
36 | + ]) |
|
37 | + ->add("url", TextType::class, [ |
|
38 | + "label" => "Url", |
|
39 | + "required" => true |
|
40 | + ]) |
|
41 | + ->add("urlAdmin", TextType::class, [ |
|
42 | + "label" => "Admin url", |
|
43 | + "required" => true |
|
44 | + ]) |
|
45 | 45 | ->add("active", CheckboxType::class, [ |
46 | 46 | "label" => "Enable module", |
47 | 47 | "attr" => [ |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | ], |
50 | 50 | "required" => false |
51 | 51 | ]) |
52 | - ->add("displayed", CheckboxType::class, [ |
|
53 | - "label" => "Display module in navigation", |
|
54 | - "attr" => [ |
|
55 | - "class" => "ribs-checkbox switched cxs-2 no-pl" |
|
56 | - ], |
|
57 | - "required" => false |
|
58 | - ]) |
|
59 | - ->add('submit', SubmitType::class, [ |
|
60 | - 'label' => 'Validate', |
|
61 | - 'attr' => [] |
|
62 | - ]); |
|
52 | + ->add("displayed", CheckboxType::class, [ |
|
53 | + "label" => "Display module in navigation", |
|
54 | + "attr" => [ |
|
55 | + "class" => "ribs-checkbox switched cxs-2 no-pl" |
|
56 | + ], |
|
57 | + "required" => false |
|
58 | + ]) |
|
59 | + ->add('submit', SubmitType::class, [ |
|
60 | + 'label' => 'Validate', |
|
61 | + 'attr' => [] |
|
62 | + ]); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function configureOptions(OptionsResolver $resolver) |
@@ -11,83 +11,83 @@ |
||
11 | 11 | |
12 | 12 | class ModuleController extends AbstractController |
13 | 13 | { |
14 | - /** |
|
15 | - * @Route("/modules/", name="ribsadmin_modules") |
|
16 | - * @return Response |
|
17 | - * function that return a list of all modules |
|
18 | - */ |
|
19 | - public function List(): Response |
|
20 | - { |
|
21 | - $em = $this->getDoctrine()->getManager(); |
|
14 | + /** |
|
15 | + * @Route("/modules/", name="ribsadmin_modules") |
|
16 | + * @return Response |
|
17 | + * function that return a list of all modules |
|
18 | + */ |
|
19 | + public function List(): Response |
|
20 | + { |
|
21 | + $em = $this->getDoctrine()->getManager(); |
|
22 | 22 | |
23 | - $modules = $em->getRepository(Module::class)->findBy([], ['titleTag' => 'ASC']); |
|
23 | + $modules = $em->getRepository(Module::class)->findBy([], ['titleTag' => 'ASC']); |
|
24 | 24 | |
25 | - return $this->render('@RibsAdmin/modules/list.html.twig', [ |
|
26 | - "modules" => $modules, |
|
27 | - ]); |
|
28 | - } |
|
25 | + return $this->render('@RibsAdmin/modules/list.html.twig', [ |
|
26 | + "modules" => $modules, |
|
27 | + ]); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @Route("/modules/create/", name="ribsadmin_modules_create") |
|
32 | - * @Route("/modules/edit/{id}", name="ribsadmin_modules_edit") |
|
33 | - * @param Request $request |
|
34 | - * @param int|null $id |
|
35 | - * @return Response |
|
36 | - * method to edit a module |
|
37 | - */ |
|
38 | - public function edit(Request $request, int $id = null): Response |
|
39 | - { |
|
40 | - $em = $this->getDoctrine()->getManager(); |
|
30 | + /** |
|
31 | + * @Route("/modules/create/", name="ribsadmin_modules_create") |
|
32 | + * @Route("/modules/edit/{id}", name="ribsadmin_modules_edit") |
|
33 | + * @param Request $request |
|
34 | + * @param int|null $id |
|
35 | + * @return Response |
|
36 | + * method to edit a module |
|
37 | + */ |
|
38 | + public function edit(Request $request, int $id = null): Response |
|
39 | + { |
|
40 | + $em = $this->getDoctrine()->getManager(); |
|
41 | 41 | |
42 | - if (!$id) { |
|
43 | - $module = new Module(); |
|
44 | - $text = "created"; |
|
45 | - } else { |
|
46 | - $module = $em->getRepository(Module::class)->findOneBy(["id" => $id]); |
|
47 | - $text = "edited"; |
|
48 | - } |
|
42 | + if (!$id) { |
|
43 | + $module = new Module(); |
|
44 | + $text = "created"; |
|
45 | + } else { |
|
46 | + $module = $em->getRepository(Module::class)->findOneBy(["id" => $id]); |
|
47 | + $text = "edited"; |
|
48 | + } |
|
49 | 49 | |
50 | - $form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Module::class, $module); |
|
51 | - $form->handleRequest($request); |
|
50 | + $form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Module::class, $module); |
|
51 | + $form->handleRequest($request); |
|
52 | 52 | |
53 | - if ($form->isSubmitted() && $form->isValid()) { |
|
54 | - /** @var Module $data */ |
|
55 | - $data = $form->getData(); |
|
56 | - $em->persist($data); |
|
57 | - $em->flush(); |
|
58 | - $this->addFlash("success-flash", "Module ". $data->getTitleTag() . " was " . $text); |
|
53 | + if ($form->isSubmitted() && $form->isValid()) { |
|
54 | + /** @var Module $data */ |
|
55 | + $data = $form->getData(); |
|
56 | + $em->persist($data); |
|
57 | + $em->flush(); |
|
58 | + $this->addFlash("success-flash", "Module ". $data->getTitleTag() . " was " . $text); |
|
59 | 59 | |
60 | - return $this->redirectToRoute("ribsadmin_modules"); |
|
61 | - } |
|
60 | + return $this->redirectToRoute("ribsadmin_modules"); |
|
61 | + } |
|
62 | 62 | |
63 | - return $this->render("@RibsAdmin/modules/edit.html.twig", [ |
|
64 | - "form" => $form->createView(), |
|
65 | - "form_errors" => $form->getErrors(), |
|
66 | - "module" => $module |
|
67 | - ]); |
|
68 | - } |
|
63 | + return $this->render("@RibsAdmin/modules/edit.html.twig", [ |
|
64 | + "form" => $form->createView(), |
|
65 | + "form_errors" => $form->getErrors(), |
|
66 | + "module" => $module |
|
67 | + ]); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @Route("/modules/delete/{id}", name="ribsadmin_modules_delete") |
|
72 | - * @param Request $request |
|
73 | - * @param int $id |
|
74 | - * @return RedirectResponse |
|
75 | - * method to delete a module |
|
76 | - */ |
|
77 | - public function delete(Request $request, int $id): RedirectResponse |
|
78 | - { |
|
79 | - $em = $this->getDoctrine()->getManager(); |
|
80 | - $module = $em->getRepository(Module::class)->findOneBy(["id" => $id]); |
|
70 | + /** |
|
71 | + * @Route("/modules/delete/{id}", name="ribsadmin_modules_delete") |
|
72 | + * @param Request $request |
|
73 | + * @param int $id |
|
74 | + * @return RedirectResponse |
|
75 | + * method to delete a module |
|
76 | + */ |
|
77 | + public function delete(Request $request, int $id): RedirectResponse |
|
78 | + { |
|
79 | + $em = $this->getDoctrine()->getManager(); |
|
80 | + $module = $em->getRepository(Module::class)->findOneBy(["id" => $id]); |
|
81 | 81 | |
82 | - if ($module) { |
|
83 | - $name = $module->getTitle(); |
|
84 | - $em->remove($module); |
|
85 | - $em->flush(); |
|
86 | - $this->addFlash("success-flash", "Module " . $name . " was deleted"); |
|
87 | - } else { |
|
88 | - $this->addFlash("error-flash", "An error occured, module doesn't found"); |
|
89 | - } |
|
82 | + if ($module) { |
|
83 | + $name = $module->getTitle(); |
|
84 | + $em->remove($module); |
|
85 | + $em->flush(); |
|
86 | + $this->addFlash("success-flash", "Module " . $name . " was deleted"); |
|
87 | + } else { |
|
88 | + $this->addFlash("error-flash", "An error occured, module doesn't found"); |
|
89 | + } |
|
90 | 90 | |
91 | - return $this->redirectToRoute("ribsadmin_modules"); |
|
92 | - } |
|
91 | + return $this->redirectToRoute("ribsadmin_modules"); |
|
92 | + } |
|
93 | 93 | } |
@@ -13,64 +13,64 @@ |
||
13 | 13 | |
14 | 14 | class ImportModuleCommand extends Command |
15 | 15 | { |
16 | - private $em; |
|
16 | + private $em; |
|
17 | 17 | |
18 | - /** |
|
19 | - * ImportModuleCommand constructor. |
|
20 | - * @param EntityManagerInterface $em |
|
21 | - * @param string|null $name |
|
22 | - */ |
|
23 | - public function __construct(EntityManagerInterface $em, string $name = null) |
|
24 | - { |
|
25 | - parent::__construct($name); |
|
26 | - $this->em = $em; |
|
27 | - } |
|
18 | + /** |
|
19 | + * ImportModuleCommand constructor. |
|
20 | + * @param EntityManagerInterface $em |
|
21 | + * @param string|null $name |
|
22 | + */ |
|
23 | + public function __construct(EntityManagerInterface $em, string $name = null) |
|
24 | + { |
|
25 | + parent::__construct($name); |
|
26 | + $this->em = $em; |
|
27 | + } |
|
28 | 28 | |
29 | - protected function configure() |
|
30 | - { |
|
31 | - $this |
|
32 | - ->setName('ribsadmin:import-module') |
|
33 | - ->setDescription('Import a module in ribs admin') |
|
34 | - ->addArgument( |
|
35 | - 'package-name', |
|
36 | - InputArgument::REQUIRED, |
|
37 | - 'Name of composer package to import' |
|
38 | - ) |
|
39 | - ->addArgument( |
|
40 | - 'module-name', |
|
41 | - InputArgument::REQUIRED, |
|
42 | - 'Name of package to display in app' |
|
43 | - ) |
|
44 | - ; |
|
45 | - } |
|
29 | + protected function configure() |
|
30 | + { |
|
31 | + $this |
|
32 | + ->setName('ribsadmin:import-module') |
|
33 | + ->setDescription('Import a module in ribs admin') |
|
34 | + ->addArgument( |
|
35 | + 'package-name', |
|
36 | + InputArgument::REQUIRED, |
|
37 | + 'Name of composer package to import' |
|
38 | + ) |
|
39 | + ->addArgument( |
|
40 | + 'module-name', |
|
41 | + InputArgument::REQUIRED, |
|
42 | + 'Name of package to display in app' |
|
43 | + ) |
|
44 | + ; |
|
45 | + } |
|
46 | 46 | |
47 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
48 | - { |
|
49 | - $pacakge_name = $input->getArgument('package-name'); |
|
50 | - $output->writeln("Start composer require " . $pacakge_name); |
|
47 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
48 | + { |
|
49 | + $pacakge_name = $input->getArgument('package-name'); |
|
50 | + $output->writeln("Start composer require " . $pacakge_name); |
|
51 | 51 | |
52 | - $process = new Process("composer require " . $pacakge_name); |
|
53 | - $process->run(function ($type, $buffer) { |
|
54 | - echo $buffer; |
|
55 | - }); |
|
52 | + $process = new Process("composer require " . $pacakge_name); |
|
53 | + $process->run(function ($type, $buffer) { |
|
54 | + echo $buffer; |
|
55 | + }); |
|
56 | 56 | |
57 | - if (!$process->isSuccessful()) { |
|
58 | - throw new ProcessFailedException($process); |
|
59 | - } |
|
57 | + if (!$process->isSuccessful()) { |
|
58 | + throw new ProcessFailedException($process); |
|
59 | + } |
|
60 | 60 | |
61 | - $output->writeln("End composer require " . $pacakge_name); |
|
62 | - $output->writeln("Start insertion of module in database " . $pacakge_name); |
|
61 | + $output->writeln("End composer require " . $pacakge_name); |
|
62 | + $output->writeln("Start insertion of module in database " . $pacakge_name); |
|
63 | 63 | |
64 | - $module = new Module(); |
|
65 | - $module->setPackageName($pacakge_name); |
|
66 | - $module->setTitle($input->getArgument('module-name')); |
|
67 | - $module->setActive(false); |
|
68 | - $module->setDisplayed(true); |
|
69 | - $this->em->persist($module); |
|
70 | - $this->em->flush(); |
|
64 | + $module = new Module(); |
|
65 | + $module->setPackageName($pacakge_name); |
|
66 | + $module->setTitle($input->getArgument('module-name')); |
|
67 | + $module->setActive(false); |
|
68 | + $module->setDisplayed(true); |
|
69 | + $this->em->persist($module); |
|
70 | + $this->em->flush(); |
|
71 | 71 | |
72 | - $output->writeln("Installation of " . $pacakge_name . " is finished. You have now to configure this module in your administration interface"); |
|
72 | + $output->writeln("Installation of " . $pacakge_name . " is finished. You have now to configure this module in your administration interface"); |
|
73 | 73 | |
74 | - return 0; |
|
75 | - } |
|
74 | + return 0; |
|
75 | + } |
|
76 | 76 | } |