Passed
Push — master ( 642c1d...0bd730 )
by Anthony
02:55
created
Command/ImportModuleCommand.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -13,64 +13,64 @@
 block discarded – undo
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
-        $package_name = $input->getArgument('package-name');
50
-        $output->writeln("Start composer require " . $package_name);
47
+				protected function execute(InputInterface $input, OutputInterface $output)
48
+				{
49
+								$package_name = $input->getArgument('package-name');
50
+								$output->writeln("Start composer require " . $package_name);
51 51
 
52
-        $process = Process::fromShellCommandline("composer require " . $package_name);
53
-        $process->run(function ($type, $buffer) {
54
-            echo $buffer;
55
-        });
52
+								$process = Process::fromShellCommandline("composer require " . $package_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 " . $package_name);
62
-        $output->writeln("Start insertion of module in database " . $package_name);
61
+								$output->writeln("End composer require " . $package_name);
62
+								$output->writeln("Start insertion of module in database " . $package_name);
63 63
 
64
-        $module = new Module();
65
-        $module->setPackageName($package_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($package_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 " . $package_name . " is finished. You have now to configure this module in your administration interface");
72
+								$output->writeln("Installation of " . $package_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
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
         $output->writeln("Start composer require " . $package_name);
51 51
 
52 52
         $process = Process::fromShellCommandline("composer require " . $package_name);
53
-        $process->run(function ($type, $buffer) {
53
+        $process->run(function($type, $buffer) {
54 54
             echo $buffer;
55 55
         });
56 56
 
Please login to merge, or discard this patch.
Command/ChangePackageVersionCommand.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -12,52 +12,52 @@
 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
-    }
27
-
28
-    protected function execute(InputInterface $input, OutputInterface $output)
29
-    {
30
-        $fs = new Filesystem();
31
-        $cd = "";
32
-
33
-        if (!$fs->exists("composer.json") && $fs->exists("index.php")) {
34
-            $cd = "cd .. && ";
35
-        }
36
-
37
-        $package_name = $input->getArgument('package-name');
38
-        $output->writeln("Start composer require " . $package_name);
39
-
40
-        $process = Process::fromShellCommandline($cd . "chmod 777 composer.json");
41
-        $process->run(function ($type, $buffer) {
42
-            echo $buffer;
43
-        });
44
-
45
-        $process = Process::fromShellCommandline($cd . "composer require " . $package_name);
46
-        $process->run(function ($type, $buffer) {
47
-            echo $buffer;
48
-        });
49
-
50
-        if (!$process->isSuccessful()) {
51
-            throw new ProcessFailedException($process);
52
-        }
53
-
54
-        $process = Process::fromShellCommandline($cd . "chmod 644 composer.json");
55
-        $process->run(function ($type, $buffer) {
56
-            echo $buffer;
57
-        });
58
-
59
-        $output->writeln("Change version of " . $package_name . " is finished.");
60
-
61
-        return 0;
62
-    }
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
+
28
+				protected function execute(InputInterface $input, OutputInterface $output)
29
+				{
30
+								$fs = new Filesystem();
31
+								$cd = "";
32
+
33
+								if (!$fs->exists("composer.json") && $fs->exists("index.php")) {
34
+												$cd = "cd .. && ";
35
+								}
36
+
37
+								$package_name = $input->getArgument('package-name');
38
+								$output->writeln("Start composer require " . $package_name);
39
+
40
+								$process = Process::fromShellCommandline($cd . "chmod 777 composer.json");
41
+								$process->run(function ($type, $buffer) {
42
+												echo $buffer;
43
+								});
44
+
45
+								$process = Process::fromShellCommandline($cd . "composer require " . $package_name);
46
+								$process->run(function ($type, $buffer) {
47
+												echo $buffer;
48
+								});
49
+
50
+								if (!$process->isSuccessful()) {
51
+												throw new ProcessFailedException($process);
52
+								}
53
+
54
+								$process = Process::fromShellCommandline($cd . "chmod 644 composer.json");
55
+								$process->run(function ($type, $buffer) {
56
+												echo $buffer;
57
+								});
58
+
59
+								$output->writeln("Change version of " . $package_name . " is finished.");
60
+
61
+								return 0;
62
+				}
63 63
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
         $output->writeln("Start composer require " . $package_name);
39 39
 
40 40
         $process = Process::fromShellCommandline($cd . "chmod 777 composer.json");
41
-        $process->run(function ($type, $buffer) {
41
+        $process->run(function($type, $buffer) {
42 42
             echo $buffer;
43 43
         });
44 44
 
45 45
         $process = Process::fromShellCommandline($cd . "composer require " . $package_name);
46
-        $process->run(function ($type, $buffer) {
46
+        $process->run(function($type, $buffer) {
47 47
             echo $buffer;
48 48
         });
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         }
53 53
 
54 54
         $process = Process::fromShellCommandline($cd . "chmod 644 composer.json");
55
-        $process->run(function ($type, $buffer) {
55
+        $process->run(function($type, $buffer) {
56 56
             echo $buffer;
57 57
         });
58 58
 
Please login to merge, or discard this patch.
Service/Version.php 2 patches
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -15,219 +15,219 @@
 block discarded – undo
15 15
 
16 16
 class Version
17 17
 {
18
-    /**
19
-     * @var EntityManagerInterface
20
-     */
21
-    private $em;
22
-
23
-    /**
24
-     * @var HttpClientInterface
25
-     */
26
-    private $client;
27
-
28
-    /**
29
-     * @var ParameterBagInterface
30
-     */
31
-    private $parameter;
32
-
33
-    /**
34
-     * @var PackagistApi
35
-     */
36
-    private $packagist;
37
-
38
-    /**
39
-     * @var mixed
40
-     */
41
-    private $local_token;
42
-
43
-    /**
44
-     * @var Package
45
-     */
46
-    private $package;
47
-
48
-    private $messages = [];
49
-
50
-    /**
51
-     * Version constructor.
52
-     * @param EntityManagerInterface $em
53
-     * @param HttpClientInterface $client
54
-     * @param ParameterBagInterface $parameter
55
-     * @param PackagistApi $packagist
56
-     */
57
-    public function __construct(EntityManagerInterface $em, HttpClientInterface $client, ParameterBagInterface $parameter, PackagistApi $packagist)
58
-    {
59
-        $this->em = $em;
60
-        $this->client = $client;
61
-        $this->parameter = $parameter;
62
-        $this->packagist = $packagist;
63
-        $this->local_token = $parameter->get("ribs_admin.packages_token");
64
-    }
65
-
66
-    /**
67
-     * @return array
68
-     */
69
-    public function getMessages(): array
70
-    {
71
-        return $this->messages;
72
-    }
73
-
74
-    /**
75
-     * @param Package $package
76
-     */
77
-    public function setPackageEntity(Package $package)
78
-    {
79
-        $this->package = $package;
80
-    }
81
-
82
-    /**
83
-     * @return mixed|null
84
-     * @throws ClientExceptionInterface
85
-     * @throws RedirectionExceptionInterface
86
-     * @throws ServerExceptionInterface
87
-     * @throws TransportExceptionInterface
88
-     */
89
-    private function getToken()
90
-    {
91
-        $token = null;
92
-        $response = $this->client->request("GET", $this->package->getProjectUrl()."ribs-admin/packages/dist/send-token/");
93
-        $datas = $response->getStatusCode() == 200 ? $response->getContent() : null;
94
-
95
-        if ($datas) {
96
-            $token = json_decode($datas, true)["token"];
97
-        }
98
-
99
-        return $token;
100
-    }
101
-
102
-    /**
103
-     * @return mixed|null
104
-     * @throws ClientExceptionInterface
105
-     * @throws RedirectionExceptionInterface
106
-     * @throws ServerExceptionInterface
107
-     * @throws TransportExceptionInterface
108
-     */
109
-    private function getComposerLockJson()
110
-    {
111
-        if ($this->package && !$this->package->isIsLocal()) {
112
-            $response = $this->client->request("GET", $this->package->getProjectUrl().$this->package->getComposerLockUrl());
113
-            $composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null;
114
-        } else {
115
-            $composer_lock = file_get_contents('../composer.lock');
116
-        }
117
-
118
-        if ($composer_lock) {
119
-            return json_decode($composer_lock, true);
120
-        }
121
-
122
-        return null;
123
-    }
124
-
125
-    /**
126
-     * @return mixed|null
127
-     * @throws ClientExceptionInterface
128
-     * @throws RedirectionExceptionInterface
129
-     * @throws ServerExceptionInterface
130
-     * @throws TransportExceptionInterface
131
-     */
132
-    public function getPackage()
133
-    {
134
-        $composer_lock = $this->getComposerLockJson();
135
-        if ($composer_lock) {
136
-            $packages = $composer_lock["packages"];
137
-            $key = array_search($this->package->getPackageName(), array_column($packages, 'name'));
138
-
139
-            if ($key) {
140
-                return $packages[$key];
141
-            }
142
-        }
143
-
144
-        $this->messages["composer_lock"] = "Composer lock not found at " . $this->package->getProjectUrl();
145
-
146
-        return null;
147
-    }
148
-
149
-    /**
150
-     * @return mixed|null
151
-     * @throws ClientExceptionInterface
152
-     * @throws RedirectionExceptionInterface
153
-     * @throws ServerExceptionInterface
154
-     * @throws TransportExceptionInterface
155
-     */
156
-    public function getVersion()
157
-    {
158
-        return $this->getPackage($this->package->getPackageName()) ? $this->getPackage($this->package->getPackageName())["version"] : null;
159
-    }
160
-
161
-    /**
162
-     * @return DateTime|null
163
-     * @throws Exception
164
-     */
165
-    public function getVersionDate(): ?DateTime
166
-    {
167
-        $string_date = $this->getPackage($this->package->getPackageName()) ? explode("T", $this->getPackage($this->package->getPackageName())["time"])[0] : null;
168
-        $version_date = null;
169
-
170
-        if ($string_date) {
171
-            $version_date = new DateTime($string_date);
172
-        }
173
-
174
-        return $version_date;
175
-    }
176
-
177
-    /**
178
-     * @param string $guid
179
-     * @param string $version
180
-     * @return string|void|null
181
-     * @throws ClientExceptionInterface
182
-     * @throws RedirectionExceptionInterface
183
-     * @throws ServerExceptionInterface
184
-     * @throws TransportExceptionInterface
185
-     */
186
-    public function updatePackage(string $guid, string $version)
187
-    {
188
-        $package = $this->em->getRepository(Package::class)->findOneBy(["guid" => $guid]);
189
-
190
-        if ($package) {
191
-            $this->setPackageEntity($package);
192
-
193
-            if (!$this->getToken() || $this->getToken() !== $this->local_token) {
194
-                $this->messages["token_error"] = "Token not matching on : " . $this->package->getProjectUrl();
195
-                return;
196
-            }
197
-
198
-            $response = $this->client->request("GET", $this->package->getProjectUrl().'ribs-admin/packages/dist/change-version/'.$package->getPackageName().':'.$version);
199
-            $this->save($guid);
200
-
201
-            return $response->getStatusCode() == 200 ? $response->getContent() : null;
202
-        }
203
-    }
204
-
205
-    /**
206
-     * @param string $package_guid
207
-     * @throws ClientExceptionInterface
208
-     * @throws RedirectionExceptionInterface
209
-     * @throws ServerExceptionInterface
210
-     * @throws TransportExceptionInterface
211
-     */
212
-    public function save(string $package_guid)
213
-    {
214
-        $package = $this->em->getRepository(Package::class)->findOneBy(["guid" => $package_guid]);
215
-
216
-        if ($package) {
217
-            $this->setPackageEntity($package);
218
-
219
-            if (!$this->getToken() || $this->getToken() !== $this->local_token) {
220
-                $this->messages["token_error"] = "Token not matching on : " . $this->package->getProjectUrl();
221
-                return;
222
-            }
223
-
224
-            $package->setVersion($this->getVersion());
225
-            $package->setVersionDate($this->getVersionDate());
226
-            $package->setLastPackagistVersion($this->packagist->getLastPackagistVersion($package->getPackageName()));
227
-            $package->setLastCheck(new DateTime());
228
-
229
-            $this->em->persist($package);
230
-            $this->em->flush();
231
-        }
232
-    }
18
+				/**
19
+				 * @var EntityManagerInterface
20
+				 */
21
+				private $em;
22
+
23
+				/**
24
+				 * @var HttpClientInterface
25
+				 */
26
+				private $client;
27
+
28
+				/**
29
+				 * @var ParameterBagInterface
30
+				 */
31
+				private $parameter;
32
+
33
+				/**
34
+				 * @var PackagistApi
35
+				 */
36
+				private $packagist;
37
+
38
+				/**
39
+				 * @var mixed
40
+				 */
41
+				private $local_token;
42
+
43
+				/**
44
+				 * @var Package
45
+				 */
46
+				private $package;
47
+
48
+				private $messages = [];
49
+
50
+				/**
51
+				 * Version constructor.
52
+				 * @param EntityManagerInterface $em
53
+				 * @param HttpClientInterface $client
54
+				 * @param ParameterBagInterface $parameter
55
+				 * @param PackagistApi $packagist
56
+				 */
57
+				public function __construct(EntityManagerInterface $em, HttpClientInterface $client, ParameterBagInterface $parameter, PackagistApi $packagist)
58
+				{
59
+								$this->em = $em;
60
+								$this->client = $client;
61
+								$this->parameter = $parameter;
62
+								$this->packagist = $packagist;
63
+								$this->local_token = $parameter->get("ribs_admin.packages_token");
64
+				}
65
+
66
+				/**
67
+				 * @return array
68
+				 */
69
+				public function getMessages(): array
70
+				{
71
+								return $this->messages;
72
+				}
73
+
74
+				/**
75
+				 * @param Package $package
76
+				 */
77
+				public function setPackageEntity(Package $package)
78
+				{
79
+								$this->package = $package;
80
+				}
81
+
82
+				/**
83
+				 * @return mixed|null
84
+				 * @throws ClientExceptionInterface
85
+				 * @throws RedirectionExceptionInterface
86
+				 * @throws ServerExceptionInterface
87
+				 * @throws TransportExceptionInterface
88
+				 */
89
+				private function getToken()
90
+				{
91
+								$token = null;
92
+								$response = $this->client->request("GET", $this->package->getProjectUrl()."ribs-admin/packages/dist/send-token/");
93
+								$datas = $response->getStatusCode() == 200 ? $response->getContent() : null;
94
+
95
+								if ($datas) {
96
+												$token = json_decode($datas, true)["token"];
97
+								}
98
+
99
+								return $token;
100
+				}
101
+
102
+				/**
103
+				 * @return mixed|null
104
+				 * @throws ClientExceptionInterface
105
+				 * @throws RedirectionExceptionInterface
106
+				 * @throws ServerExceptionInterface
107
+				 * @throws TransportExceptionInterface
108
+				 */
109
+				private function getComposerLockJson()
110
+				{
111
+								if ($this->package && !$this->package->isIsLocal()) {
112
+												$response = $this->client->request("GET", $this->package->getProjectUrl().$this->package->getComposerLockUrl());
113
+												$composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null;
114
+								} else {
115
+												$composer_lock = file_get_contents('../composer.lock');
116
+								}
117
+
118
+								if ($composer_lock) {
119
+												return json_decode($composer_lock, true);
120
+								}
121
+
122
+								return null;
123
+				}
124
+
125
+				/**
126
+				 * @return mixed|null
127
+				 * @throws ClientExceptionInterface
128
+				 * @throws RedirectionExceptionInterface
129
+				 * @throws ServerExceptionInterface
130
+				 * @throws TransportExceptionInterface
131
+				 */
132
+				public function getPackage()
133
+				{
134
+								$composer_lock = $this->getComposerLockJson();
135
+								if ($composer_lock) {
136
+												$packages = $composer_lock["packages"];
137
+												$key = array_search($this->package->getPackageName(), array_column($packages, 'name'));
138
+
139
+												if ($key) {
140
+																return $packages[$key];
141
+												}
142
+								}
143
+
144
+								$this->messages["composer_lock"] = "Composer lock not found at " . $this->package->getProjectUrl();
145
+
146
+								return null;
147
+				}
148
+
149
+				/**
150
+				 * @return mixed|null
151
+				 * @throws ClientExceptionInterface
152
+				 * @throws RedirectionExceptionInterface
153
+				 * @throws ServerExceptionInterface
154
+				 * @throws TransportExceptionInterface
155
+				 */
156
+				public function getVersion()
157
+				{
158
+								return $this->getPackage($this->package->getPackageName()) ? $this->getPackage($this->package->getPackageName())["version"] : null;
159
+				}
160
+
161
+				/**
162
+				 * @return DateTime|null
163
+				 * @throws Exception
164
+				 */
165
+				public function getVersionDate(): ?DateTime
166
+				{
167
+								$string_date = $this->getPackage($this->package->getPackageName()) ? explode("T", $this->getPackage($this->package->getPackageName())["time"])[0] : null;
168
+								$version_date = null;
169
+
170
+								if ($string_date) {
171
+												$version_date = new DateTime($string_date);
172
+								}
173
+
174
+								return $version_date;
175
+				}
176
+
177
+				/**
178
+				 * @param string $guid
179
+				 * @param string $version
180
+				 * @return string|void|null
181
+				 * @throws ClientExceptionInterface
182
+				 * @throws RedirectionExceptionInterface
183
+				 * @throws ServerExceptionInterface
184
+				 * @throws TransportExceptionInterface
185
+				 */
186
+				public function updatePackage(string $guid, string $version)
187
+				{
188
+								$package = $this->em->getRepository(Package::class)->findOneBy(["guid" => $guid]);
189
+
190
+								if ($package) {
191
+												$this->setPackageEntity($package);
192
+
193
+												if (!$this->getToken() || $this->getToken() !== $this->local_token) {
194
+																$this->messages["token_error"] = "Token not matching on : " . $this->package->getProjectUrl();
195
+																return;
196
+												}
197
+
198
+												$response = $this->client->request("GET", $this->package->getProjectUrl().'ribs-admin/packages/dist/change-version/'.$package->getPackageName().':'.$version);
199
+												$this->save($guid);
200
+
201
+												return $response->getStatusCode() == 200 ? $response->getContent() : null;
202
+								}
203
+				}
204
+
205
+				/**
206
+				 * @param string $package_guid
207
+				 * @throws ClientExceptionInterface
208
+				 * @throws RedirectionExceptionInterface
209
+				 * @throws ServerExceptionInterface
210
+				 * @throws TransportExceptionInterface
211
+				 */
212
+				public function save(string $package_guid)
213
+				{
214
+								$package = $this->em->getRepository(Package::class)->findOneBy(["guid" => $package_guid]);
215
+
216
+								if ($package) {
217
+												$this->setPackageEntity($package);
218
+
219
+												if (!$this->getToken() || $this->getToken() !== $this->local_token) {
220
+																$this->messages["token_error"] = "Token not matching on : " . $this->package->getProjectUrl();
221
+																return;
222
+												}
223
+
224
+												$package->setVersion($this->getVersion());
225
+												$package->setVersionDate($this->getVersionDate());
226
+												$package->setLastPackagistVersion($this->packagist->getLastPackagistVersion($package->getPackageName()));
227
+												$package->setLastCheck(new DateTime());
228
+
229
+												$this->em->persist($package);
230
+												$this->em->flush();
231
+								}
232
+				}
233 233
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     private function getToken()
90 90
     {
91 91
         $token = null;
92
-        $response = $this->client->request("GET", $this->package->getProjectUrl()."ribs-admin/packages/dist/send-token/");
92
+        $response = $this->client->request("GET", $this->package->getProjectUrl() . "ribs-admin/packages/dist/send-token/");
93 93
         $datas = $response->getStatusCode() == 200 ? $response->getContent() : null;
94 94
 
95 95
         if ($datas) {
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     private function getComposerLockJson()
110 110
     {
111 111
         if ($this->package && !$this->package->isIsLocal()) {
112
-            $response = $this->client->request("GET", $this->package->getProjectUrl().$this->package->getComposerLockUrl());
112
+            $response = $this->client->request("GET", $this->package->getProjectUrl() . $this->package->getComposerLockUrl());
113 113
             $composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null;
114 114
         } else {
115 115
             $composer_lock = file_get_contents('../composer.lock');
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                 return;
196 196
             }
197 197
 
198
-            $response = $this->client->request("GET", $this->package->getProjectUrl().'ribs-admin/packages/dist/change-version/'.$package->getPackageName().':'.$version);
198
+            $response = $this->client->request("GET", $this->package->getProjectUrl() . 'ribs-admin/packages/dist/change-version/' . $package->getPackageName() . ':' . $version);
199 199
             $this->save($guid);
200 200
 
201 201
             return $response->getStatusCode() == 200 ? $response->getContent() : null;
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 new Response($response, 200, ["Content-Type" => "text/html"]);
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 new Response($response, 200, ["Content-Type" => "text/html"]);
151
+								}
152
+
153
+								return $this->redirectToRoute("ribsadmin_packages_update", ["guid" => $guid]);
154
+				}
155 155
 }
Please login to merge, or discard this patch.