Passed
Push — master ( 209bed...a0774b )
by Anthony
02:41
created
Controller/PackagesDistController.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -21,111 +21,111 @@
 block discarded – undo
21 21
 
22 22
 class PackagesDistController extends AbstractController
23 23
 {
24
-    /**
25
-     * @Route("/packages/dist/send-package/{package_name}", name="ribsadmin_packages_dist_send", requirements={"package_name"=".+"})
26
-     * @param EntityManagerInterface $em
27
-     * @param Version $version
28
-     * @param string $package_name
29
-     * @return mixed|null
30
-     * @throws Exception
31
-     */
32
-    public function sendPackageInformations(EntityManagerInterface $em, Version $version, string $package_name): JsonResponse
33
-    {
34
-        $package = $em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]);
35
-
36
-        if ($package) {
37
-            $version->setPackageEntity($package);
38
-        }
39
-
40
-        return new JsonResponse([
41
-            "package" => $version->getPackage(),
42
-            "package_date" => $version->getVersionDate()
43
-        ]);
44
-    }
45
-
46
-    /**
47
-     * @Route("/packages/dist/send-composer-lock/", name="ribsadmin_packages_dist_send_composer_lock")
48
-     * @return JsonResponse
49
-     */
50
-    public function sendComposerJson(): JsonResponse
51
-    {
52
-        $composer_lock = file_get_contents('../composer.lock');
53
-
54
-        if ($composer_lock) {
55
-            $composer_lock = json_decode($composer_lock);
56
-        }
57
-
58
-        return new JsonResponse($composer_lock);
59
-    }
60
-
61
-    /**
62
-     * @Route("/packages/dist/send-token/", name="ribsadmin_packages_dist_send_token")
63
-     * @param ParameterBagInterface $parameter
64
-     * @return JsonResponse
65
-     */
66
-    public function sendToken(ParameterBagInterface $parameter): JsonResponse
67
-    {
68
-        return new JsonResponse([
69
-            "token" => $parameter->get("ribs_admin.packages_token")
70
-        ]);
71
-    }
72
-
73
-    /**
74
-     * @param $file
75
-     * @param $folder
76
-     * @return bool
77
-     */
78
-    private function uploadConfigFile($file, $folder)
79
-    {
80
-        $success = true;
81
-        if ($file) {
82
-            try {
83
-                $file->move('../config/'.$folder, $file->getClientOriginalName());
84
-            } catch (FileException $exception) {
85
-                $success = false;
86
-            }
87
-        }
88
-        return $success;
89
-    }
90
-
91
-    /**
92
-     * @Route("/packages/dist/change-version/", name="ribsadmin_packages_dist_change_version", requirements={"package_name"=".+"}, methods={"POST"})
93
-     * @param KernelInterface $kernel
94
-     * @param Request $request
95
-     * @return JsonResponse
96
-     * @throws Exception
97
-     */
98
-    public function changePackageVersion(KernelInterface $kernel, Request $request): JsonResponse
99
-    {
100
-        $application = new Application($kernel);
101
-        $application->setAutoExit(false);
102
-
103
-        $package_name = $request->get("package_name");
104
-        $version = $request->get("version");
105
-
106
-        if (!$this->uploadConfigFile($request->files->get('package_routes'), "routes")) {
107
-            return new JsonResponse([
108
-                "error_message" => "Routes file move is impossible"
109
-            ]);
110
-        }
111
-
112
-        if (!$this->uploadConfigFile($request->files->get('package_config'), "packages")) {
113
-            return new JsonResponse([
114
-                "error_message" => "Package file move is impossible"
115
-            ]);
116
-        }
117
-
118
-        $input = new ArrayInput([
119
-            'command' => 'ribsadmin:change-package-version',
120
-            'package-name' => $package_name.":".$version,
121
-        ]);
122
-
123
-        $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true);
124
-        $application->run($input, $output);
125
-
126
-        $converter = new AnsiToHtmlConverter();
127
-        $content = $output->fetch();
128
-
129
-        return new JsonResponse($converter->convert($content));
130
-    }
24
+				/**
25
+				 * @Route("/packages/dist/send-package/{package_name}", name="ribsadmin_packages_dist_send", requirements={"package_name"=".+"})
26
+				 * @param EntityManagerInterface $em
27
+				 * @param Version $version
28
+				 * @param string $package_name
29
+				 * @return mixed|null
30
+				 * @throws Exception
31
+				 */
32
+				public function sendPackageInformations(EntityManagerInterface $em, Version $version, string $package_name): JsonResponse
33
+				{
34
+								$package = $em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]);
35
+
36
+								if ($package) {
37
+												$version->setPackageEntity($package);
38
+								}
39
+
40
+								return new JsonResponse([
41
+												"package" => $version->getPackage(),
42
+												"package_date" => $version->getVersionDate()
43
+								]);
44
+				}
45
+
46
+				/**
47
+				 * @Route("/packages/dist/send-composer-lock/", name="ribsadmin_packages_dist_send_composer_lock")
48
+				 * @return JsonResponse
49
+				 */
50
+				public function sendComposerJson(): JsonResponse
51
+				{
52
+								$composer_lock = file_get_contents('../composer.lock');
53
+
54
+								if ($composer_lock) {
55
+												$composer_lock = json_decode($composer_lock);
56
+								}
57
+
58
+								return new JsonResponse($composer_lock);
59
+				}
60
+
61
+				/**
62
+				 * @Route("/packages/dist/send-token/", name="ribsadmin_packages_dist_send_token")
63
+				 * @param ParameterBagInterface $parameter
64
+				 * @return JsonResponse
65
+				 */
66
+				public function sendToken(ParameterBagInterface $parameter): JsonResponse
67
+				{
68
+								return new JsonResponse([
69
+												"token" => $parameter->get("ribs_admin.packages_token")
70
+								]);
71
+				}
72
+
73
+				/**
74
+				 * @param $file
75
+				 * @param $folder
76
+				 * @return bool
77
+				 */
78
+				private function uploadConfigFile($file, $folder)
79
+				{
80
+								$success = true;
81
+								if ($file) {
82
+												try {
83
+																$file->move('../config/'.$folder, $file->getClientOriginalName());
84
+												} catch (FileException $exception) {
85
+																$success = false;
86
+												}
87
+								}
88
+								return $success;
89
+				}
90
+
91
+				/**
92
+				 * @Route("/packages/dist/change-version/", name="ribsadmin_packages_dist_change_version", requirements={"package_name"=".+"}, methods={"POST"})
93
+				 * @param KernelInterface $kernel
94
+				 * @param Request $request
95
+				 * @return JsonResponse
96
+				 * @throws Exception
97
+				 */
98
+				public function changePackageVersion(KernelInterface $kernel, Request $request): JsonResponse
99
+				{
100
+								$application = new Application($kernel);
101
+								$application->setAutoExit(false);
102
+
103
+								$package_name = $request->get("package_name");
104
+								$version = $request->get("version");
105
+
106
+								if (!$this->uploadConfigFile($request->files->get('package_routes'), "routes")) {
107
+												return new JsonResponse([
108
+																"error_message" => "Routes file move is impossible"
109
+												]);
110
+								}
111
+
112
+								if (!$this->uploadConfigFile($request->files->get('package_config'), "packages")) {
113
+												return new JsonResponse([
114
+																"error_message" => "Package file move is impossible"
115
+												]);
116
+								}
117
+
118
+								$input = new ArrayInput([
119
+												'command' => 'ribsadmin:change-package-version',
120
+												'package-name' => $package_name.":".$version,
121
+								]);
122
+
123
+								$output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true);
124
+								$application->run($input, $output);
125
+
126
+								$converter = new AnsiToHtmlConverter();
127
+								$content = $output->fetch();
128
+
129
+								return new JsonResponse($converter->convert($content));
130
+				}
131 131
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $success = true;
81 81
         if ($file) {
82 82
             try {
83
-                $file->move('../config/'.$folder, $file->getClientOriginalName());
83
+                $file->move('../config/' . $folder, $file->getClientOriginalName());
84 84
             } catch (FileException $exception) {
85 85
                 $success = false;
86 86
             }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
         $input = new ArrayInput([
119 119
             'command' => 'ribsadmin:change-package-version',
120
-            'package-name' => $package_name.":".$version,
120
+            'package-name' => $package_name . ":" . $version,
121 121
         ]);
122 122
 
123 123
         $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true);
Please login to merge, or discard this patch.
EventListener/ExceptionListener.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
             $ch = curl_init();
30 30
             curl_setopt($ch, CURLOPT_URL, $slack_webhook);
31 31
             curl_setopt($ch, CURLOPT_POST, 1);
32
-            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json)));
32
+            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_json)));
33 33
             curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
34 34
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
35 35
             curl_exec($ch);
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -9,50 +9,50 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
EventListener/CreateUpdateAwareListener.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -7,43 +7,43 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Controller/NavigationBuilderController.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -10,49 +10,49 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,7 @@
 block discarded – undo
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")) {
Please login to merge, or discard this patch.