Passed
Push — master ( 0bd730...5abb5b )
by Anthony
02:44
created
Controller/PackagesDistController.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -19,78 +19,78 @@
 block discarded – undo
19 19
 
20 20
 class PackagesDistController extends AbstractController
21 21
 {
22
-    /**
23
-     * @Route("/packages/dist/send-package/{package_name}", name="ribsadmin_packages_dist_send", requirements={"package_name"=".+"})
24
-     * @param EntityManagerInterface $em
25
-     * @param Version $version
26
-     * @param string $package_name
27
-     * @return mixed|null
28
-     * @throws Exception
29
-     */
30
-    public function sendPackageInformations(EntityManagerInterface $em, Version $version, string $package_name): JsonResponse
31
-    {
32
-        $package = $em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]);
22
+				/**
23
+				 * @Route("/packages/dist/send-package/{package_name}", name="ribsadmin_packages_dist_send", requirements={"package_name"=".+"})
24
+				 * @param EntityManagerInterface $em
25
+				 * @param Version $version
26
+				 * @param string $package_name
27
+				 * @return mixed|null
28
+				 * @throws Exception
29
+				 */
30
+				public function sendPackageInformations(EntityManagerInterface $em, Version $version, string $package_name): JsonResponse
31
+				{
32
+								$package = $em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]);
33 33
 
34
-        if ($package) {
35
-            $version->setPackageEntity($package);
36
-        }
34
+								if ($package) {
35
+												$version->setPackageEntity($package);
36
+								}
37 37
 
38
-        return new JsonResponse([
39
-            "package" => $version->getPackage(),
40
-            "package_date" => $version->getVersionDate()
41
-        ]);
42
-    }
38
+								return new JsonResponse([
39
+												"package" => $version->getPackage(),
40
+												"package_date" => $version->getVersionDate()
41
+								]);
42
+				}
43 43
 
44
-    /**
45
-     * @Route("/packages/dist/send-composer-lock/", name="ribsadmin_packages_dist_send_composer_lock")
46
-     * @return JsonResponse
47
-     */
48
-    public function sendComposerJson(): JsonResponse
49
-    {
50
-        $composer_lock = file_get_contents('../composer.lock');
44
+				/**
45
+				 * @Route("/packages/dist/send-composer-lock/", name="ribsadmin_packages_dist_send_composer_lock")
46
+				 * @return JsonResponse
47
+				 */
48
+				public function sendComposerJson(): JsonResponse
49
+				{
50
+								$composer_lock = file_get_contents('../composer.lock');
51 51
 
52
-        if ($composer_lock) {
53
-            $composer_lock = json_decode($composer_lock);
54
-        }
52
+								if ($composer_lock) {
53
+												$composer_lock = json_decode($composer_lock);
54
+								}
55 55
 
56
-        return new JsonResponse($composer_lock);
57
-    }
56
+								return new JsonResponse($composer_lock);
57
+				}
58 58
 
59
-    /**
60
-     * @Route("/packages/dist/send-token/", name="ribsadmin_packages_dist_send_token")
61
-     * @param ParameterBagInterface $parameter
62
-     * @return JsonResponse
63
-     */
64
-    public function sendToken(ParameterBagInterface $parameter): JsonResponse
65
-    {
66
-        return new JsonResponse([
67
-            "token" => $parameter->get("ribs_admin.packages_token")
68
-        ]);
69
-    }
59
+				/**
60
+				 * @Route("/packages/dist/send-token/", name="ribsadmin_packages_dist_send_token")
61
+				 * @param ParameterBagInterface $parameter
62
+				 * @return JsonResponse
63
+				 */
64
+				public function sendToken(ParameterBagInterface $parameter): JsonResponse
65
+				{
66
+								return new JsonResponse([
67
+												"token" => $parameter->get("ribs_admin.packages_token")
68
+								]);
69
+				}
70 70
 
71
-    /**
72
-     * @Route("/packages/dist/change-version/{package_name}", name="ribsadmin_packages_dist_change_version", requirements={"package_name"=".+"})
73
-     * @param KernelInterface $kernel
74
-     * @param string $package_name
75
-     * @return JsonResponse
76
-     * @throws Exception
77
-     */
78
-    public function changePackageVersion(KernelInterface $kernel, string $package_name): JsonResponse
79
-    {
80
-        $application = new Application($kernel);
81
-        $application->setAutoExit(false);
71
+				/**
72
+				 * @Route("/packages/dist/change-version/{package_name}", name="ribsadmin_packages_dist_change_version", requirements={"package_name"=".+"})
73
+				 * @param KernelInterface $kernel
74
+				 * @param string $package_name
75
+				 * @return JsonResponse
76
+				 * @throws Exception
77
+				 */
78
+				public function changePackageVersion(KernelInterface $kernel, string $package_name): JsonResponse
79
+				{
80
+								$application = new Application($kernel);
81
+								$application->setAutoExit(false);
82 82
 
83
-        $input = new ArrayInput([
84
-            'command' => 'ribsadmin:change-package-version',
85
-            'package-name' => $package_name,
86
-        ]);
83
+								$input = new ArrayInput([
84
+												'command' => 'ribsadmin:change-package-version',
85
+												'package-name' => $package_name,
86
+								]);
87 87
 
88
-        $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true);
89
-        $application->run($input, $output);
88
+								$output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true);
89
+								$application->run($input, $output);
90 90
 
91
-        $converter = new AnsiToHtmlConverter();
92
-        $content = $output->fetch();
91
+								$converter = new AnsiToHtmlConverter();
92
+								$content = $output->fetch();
93 93
 
94
-        return new JsonResponse($converter->convert($content));
95
-    }
94
+								return new JsonResponse($converter->convert($content));
95
+				}
96 96
 }
Please login to merge, or discard this patch.
Controller/PackageController.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -19,137 +19,137 @@
 block discarded – undo
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 Exception
108
-     */
109
-    public function updatePackage(Version $version, string $guid): RedirectResponse
110
-    {
111
-        if ($guid) {
112
-            $version->save($guid);
113
-
114
-            if ($version->getMessages()) {
115
-                $message = "<ul>";
116
-                $message .= "<li>The project package was not well updated</li>";
117
-                foreach ($version->getMessages() as $version_message) {
118
-                    $message .= "<li>".$version_message."</li>";
119
-                }
120
-                $message .= "</ul>";
121
-
122
-                $this->addFlash("info-flash", $message);
123
-            } else {
124
-                $this->addFlash("success-flash", "The project package was updated");
125
-            }
126
-        } else {
127
-            $this->addFlash("error-flash", "The project package was not found");
128
-        }
129
-
130
-        return $this->redirectToRoute("ribsadmin_packages");
131
-    }
132
-
133
-    /**
134
-     * @Route("/packages/update-version/{guid}/{install_version}", name="ribsadmin_packages_update_version")
135
-     * @param Version $version
136
-     * @param string $guid
137
-     * @param string $install_version
138
-     * @return RedirectResponse|Response
139
-     * @throws ClientExceptionInterface
140
-     * @throws RedirectionExceptionInterface
141
-     * @throws ServerExceptionInterface
142
-     * @throws TransportExceptionInterface
143
-     */
144
-    public function changePackageVersion(Version $version, string $guid, string $install_version)
145
-    {
146
-        $response = $version->updatePackage($guid, $install_version);
147
-
148
-        if ($response) {
149
-            $response = str_replace("\n", "<br>", $response);
150
-            return $this->render("@RibsAdmin/packages/show-update-version.html.twig", ["logs" => $response]);
151
-        }
152
-
153
-        return $this->redirectToRoute("ribsadmin_packages_update", ["guid" => $guid]);
154
-    }
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 Exception
108
+				 */
109
+				public function updatePackage(Version $version, string $guid): RedirectResponse
110
+				{
111
+								if ($guid) {
112
+												$version->save($guid);
113
+
114
+												if ($version->getMessages()) {
115
+																$message = "<ul>";
116
+																$message .= "<li>The project package was not well updated</li>";
117
+																foreach ($version->getMessages() as $version_message) {
118
+																				$message .= "<li>".$version_message."</li>";
119
+																}
120
+																$message .= "</ul>";
121
+
122
+																$this->addFlash("info-flash", $message);
123
+												} else {
124
+																$this->addFlash("success-flash", "The project package was updated");
125
+												}
126
+								} else {
127
+												$this->addFlash("error-flash", "The project package was not found");
128
+								}
129
+
130
+								return $this->redirectToRoute("ribsadmin_packages");
131
+				}
132
+
133
+				/**
134
+				 * @Route("/packages/update-version/{guid}/{install_version}", name="ribsadmin_packages_update_version")
135
+				 * @param Version $version
136
+				 * @param string $guid
137
+				 * @param string $install_version
138
+				 * @return RedirectResponse|Response
139
+				 * @throws ClientExceptionInterface
140
+				 * @throws RedirectionExceptionInterface
141
+				 * @throws ServerExceptionInterface
142
+				 * @throws TransportExceptionInterface
143
+				 */
144
+				public function changePackageVersion(Version $version, string $guid, string $install_version)
145
+				{
146
+								$response = $version->updatePackage($guid, $install_version);
147
+
148
+								if ($response) {
149
+												$response = str_replace("\n", "<br>", $response);
150
+												return $this->render("@RibsAdmin/packages/show-update-version.html.twig", ["logs" => $response]);
151
+								}
152
+
153
+								return $this->redirectToRoute("ribsadmin_packages_update", ["guid" => $guid]);
154
+				}
155 155
 }
Please login to merge, or discard this patch.
Command/ChangePackageVersionCommand.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,59 +12,59 @@
 block discarded – undo
12 12
 
13 13
 class ChangePackageVersionCommand extends Command
14 14
 {
15
-    protected function configure()
16
-    {
17
-        $this
18
-            ->setName('ribsadmin:change-package-version')
19
-            ->setDescription('Change a package version')
20
-            ->addArgument(
21
-                'package-name',
22
-                InputArgument::REQUIRED,
23
-                'Name of composer package to import with version (example : piou/piou/test-bundle:1.0.0)'
24
-            )
25
-        ;
26
-    }
15
+				protected function configure()
16
+				{
17
+								$this
18
+												->setName('ribsadmin:change-package-version')
19
+												->setDescription('Change a package version')
20
+												->addArgument(
21
+																'package-name',
22
+																InputArgument::REQUIRED,
23
+																'Name of composer package to import with version (example : piou/piou/test-bundle:1.0.0)'
24
+												)
25
+								;
26
+				}
27 27
 
28
-    protected function execute(InputInterface $input, OutputInterface $output)
29
-    {
30
-        $fs = new Filesystem();
31
-        $cd = "";
28
+				protected function execute(InputInterface $input, OutputInterface $output)
29
+				{
30
+								$fs = new Filesystem();
31
+								$cd = "";
32 32
 
33
-        if (!$fs->exists("composer.json") && $fs->exists("index.php")) {
34
-            $cd = "cd .. && ";
35
-        }
33
+								if (!$fs->exists("composer.json") && $fs->exists("index.php")) {
34
+												$cd = "cd .. && ";
35
+								}
36 36
 
37
-        $package_name = $input->getArgument('package-name');
37
+								$package_name = $input->getArgument('package-name');
38 38
 
39
-        $process = Process::fromShellCommandline("echo Start composer require " . $package_name);
40
-        $process->run(function ($type, $buffer) {
41
-            echo $buffer;
42
-        });
39
+								$process = Process::fromShellCommandline("echo Start composer require " . $package_name);
40
+								$process->run(function ($type, $buffer) {
41
+												echo $buffer;
42
+								});
43 43
 
44
-        $process = Process::fromShellCommandline($cd . "chmod 777 composer.json");
45
-        $process->run(function ($type, $buffer) {
46
-            echo $buffer;
47
-        });
44
+								$process = Process::fromShellCommandline($cd . "chmod 777 composer.json");
45
+								$process->run(function ($type, $buffer) {
46
+												echo $buffer;
47
+								});
48 48
 
49
-        $process = Process::fromShellCommandline($cd . "composer require " . $package_name);
50
-        $process->run(function ($type, $buffer) {
51
-            echo $buffer;
52
-        });
49
+								$process = Process::fromShellCommandline($cd . "composer require " . $package_name);
50
+								$process->run(function ($type, $buffer) {
51
+												echo $buffer;
52
+								});
53 53
 
54
-        if (!$process->isSuccessful()) {
55
-            throw new ProcessFailedException($process);
56
-        }
54
+								if (!$process->isSuccessful()) {
55
+												throw new ProcessFailedException($process);
56
+								}
57 57
 
58
-        $process = Process::fromShellCommandline($cd . "chmod 644 composer.json");
59
-        $process->run(function ($type, $buffer) {
60
-            echo $buffer;
61
-        });
58
+								$process = Process::fromShellCommandline($cd . "chmod 644 composer.json");
59
+								$process->run(function ($type, $buffer) {
60
+												echo $buffer;
61
+								});
62 62
 
63
-        $process = Process::fromShellCommandline("echo Change version of " . $package_name . " is finished.");
64
-        $process->run(function ($type, $buffer) {
65
-            echo $buffer;
66
-        });
63
+								$process = Process::fromShellCommandline("echo Change version of " . $package_name . " is finished.");
64
+								$process->run(function ($type, $buffer) {
65
+												echo $buffer;
66
+								});
67 67
 
68
-        return 0;
69
-    }
68
+								return 0;
69
+				}
70 70
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
         $package_name = $input->getArgument('package-name');
38 38
 
39 39
         $process = Process::fromShellCommandline("echo Start composer require " . $package_name);
40
-        $process->run(function ($type, $buffer) {
40
+        $process->run(function($type, $buffer) {
41 41
             echo $buffer;
42 42
         });
43 43
 
44 44
         $process = Process::fromShellCommandline($cd . "chmod 777 composer.json");
45
-        $process->run(function ($type, $buffer) {
45
+        $process->run(function($type, $buffer) {
46 46
             echo $buffer;
47 47
         });
48 48
 
49 49
         $process = Process::fromShellCommandline($cd . "composer require " . $package_name);
50
-        $process->run(function ($type, $buffer) {
50
+        $process->run(function($type, $buffer) {
51 51
             echo $buffer;
52 52
         });
53 53
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
         $process = Process::fromShellCommandline($cd . "chmod 644 composer.json");
59
-        $process->run(function ($type, $buffer) {
59
+        $process->run(function($type, $buffer) {
60 60
             echo $buffer;
61 61
         });
62 62
 
63 63
         $process = Process::fromShellCommandline("echo Change version of " . $package_name . " is finished.");
64
-        $process->run(function ($type, $buffer) {
64
+        $process->run(function($type, $buffer) {
65 65
             echo $buffer;
66 66
         });
67 67
 
Please login to merge, or discard this patch.