@@ -14,171 +14,171 @@ |
||
14 | 14 | |
15 | 15 | class Version |
16 | 16 | { |
17 | - /** |
|
18 | - * @var EntityManagerInterface |
|
19 | - */ |
|
20 | - private $em; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var HttpClientInterface |
|
24 | - */ |
|
25 | - private $client; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var Package |
|
29 | - */ |
|
30 | - private $package; |
|
31 | - |
|
32 | - private $messages = []; |
|
33 | - |
|
34 | - /** |
|
35 | - * Version constructor. |
|
36 | - * @param EntityManagerInterface $em |
|
37 | - * @param HttpClientInterface $client |
|
38 | - */ |
|
39 | - public function __construct(EntityManagerInterface $em, HttpClientInterface $client) |
|
40 | - { |
|
41 | - $this->em = $em; |
|
42 | - $this->client = $client; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - public function getMessages(): array |
|
49 | - { |
|
50 | - return $this->messages; |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * @param Package $package |
|
55 | - */ |
|
56 | - public function setPackageEntity(Package $package) { |
|
57 | - $this->package = $package; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @return mixed|null |
|
62 | - * @throws ClientExceptionInterface |
|
63 | - * @throws RedirectionExceptionInterface |
|
64 | - * @throws ServerExceptionInterface |
|
65 | - * @throws TransportExceptionInterface |
|
66 | - */ |
|
67 | - private function getComposerLockJson() |
|
68 | - { |
|
69 | - if ($this->package && !$this->package->isIsLocal()) { |
|
70 | - $response = $this->client->request("GET", $this->package->getProjectUrl().$this->package->getComposerLockUrl()); |
|
71 | - $composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null; |
|
72 | - } else { |
|
73 | - $composer_lock = file_get_contents('../composer.lock'); |
|
74 | - } |
|
75 | - |
|
76 | - if ($composer_lock) { |
|
77 | - return json_decode($composer_lock, true); |
|
78 | - } |
|
79 | - |
|
80 | - return null; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @param $package_name |
|
85 | - * @return mixed|null |
|
86 | - * @throws ClientExceptionInterface |
|
87 | - * @throws RedirectionExceptionInterface |
|
88 | - * @throws ServerExceptionInterface |
|
89 | - * @throws TransportExceptionInterface |
|
90 | - */ |
|
91 | - public function getPackage($package_name) |
|
92 | - { |
|
93 | - $composer_lock = $this->getComposerLockJson(); |
|
94 | - if ($composer_lock) { |
|
95 | - $packages = $composer_lock["packages"]; |
|
96 | - $key = array_search($package_name, array_column($packages, 'name')); |
|
97 | - |
|
98 | - if ($key) { |
|
99 | - return $packages[$key]; |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - $this->messages["composer_lock"] = "Composer lock not found at " . $this->package->getProjectUrl(); |
|
104 | - |
|
105 | - return null; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param $package_name |
|
110 | - * @return mixed|null |
|
111 | - */ |
|
112 | - public function getVersion($package_name) |
|
113 | - { |
|
114 | - return $this->getPackage($package_name) ? $this->getPackage($package_name)["version"] : null; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @param $package_name |
|
119 | - * @return DateTime|null |
|
120 | - * @throws Exception |
|
121 | - */ |
|
122 | - public function getVersionDate($package_name): ?DateTime |
|
123 | - { |
|
124 | - $string_date = $this->getPackage($package_name) ? explode("T", $this->getPackage($package_name)["time"])[0] : null; |
|
125 | - $version_date = null; |
|
126 | - |
|
127 | - if ($string_date) { |
|
128 | - $version_date = new DateTime($string_date); |
|
129 | - } |
|
130 | - |
|
131 | - return $version_date; |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * @param $package_name |
|
136 | - * @return false|int|string|null |
|
137 | - * @throws ClientExceptionInterface |
|
138 | - * @throws RedirectionExceptionInterface |
|
139 | - * @throws ServerExceptionInterface |
|
140 | - * @throws TransportExceptionInterface |
|
141 | - */ |
|
142 | - public function getLastPackagistVersion($package_name) |
|
143 | - { |
|
144 | - if (!strpos($package_name, "/")) { |
|
145 | - return false; |
|
146 | - } |
|
147 | - |
|
148 | - $packgist_url = "https://repo.packagist.org/p/".$package_name.".json"; |
|
149 | - |
|
150 | - $response = $this->client->request("GET", $packgist_url); |
|
151 | - |
|
152 | - if ($response->getStatusCode() == 200) { |
|
153 | - $content = json_decode($response->getContent(), true); |
|
154 | - if (is_array($content) && $content["packages"] && $content["packages"][$package_name]) { |
|
155 | - return array_key_first($content["packages"][$package_name]); |
|
156 | - } |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * @param $package_name |
|
162 | - * @throws Exception |
|
163 | - */ |
|
164 | - public function save($package_name) |
|
165 | - { |
|
166 | - $package = $this->em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]); |
|
167 | - |
|
168 | - if (!$package) { |
|
169 | - $package = new Package(); |
|
170 | - $package->setProjectName($package_name); |
|
171 | - $package->setPackageName($package_name); |
|
172 | - $package->setProjectUrl($package_name); |
|
173 | - $package->setCheckVersionUrl($package_name); |
|
174 | - } |
|
175 | - |
|
176 | - $package->setVersion($this->getVersion($package_name)); |
|
177 | - $package->setVersionDate($this->getVersionDate($package_name)); |
|
178 | - $package->setLastPackagistVersion($this->getLastPackagistVersion($package_name)); |
|
179 | - $package->setLastCheck(new DateTime()); |
|
180 | - |
|
181 | - $this->em->persist($package); |
|
182 | - $this->em->flush(); |
|
183 | - } |
|
17 | + /** |
|
18 | + * @var EntityManagerInterface |
|
19 | + */ |
|
20 | + private $em; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var HttpClientInterface |
|
24 | + */ |
|
25 | + private $client; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var Package |
|
29 | + */ |
|
30 | + private $package; |
|
31 | + |
|
32 | + private $messages = []; |
|
33 | + |
|
34 | + /** |
|
35 | + * Version constructor. |
|
36 | + * @param EntityManagerInterface $em |
|
37 | + * @param HttpClientInterface $client |
|
38 | + */ |
|
39 | + public function __construct(EntityManagerInterface $em, HttpClientInterface $client) |
|
40 | + { |
|
41 | + $this->em = $em; |
|
42 | + $this->client = $client; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + public function getMessages(): array |
|
49 | + { |
|
50 | + return $this->messages; |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * @param Package $package |
|
55 | + */ |
|
56 | + public function setPackageEntity(Package $package) { |
|
57 | + $this->package = $package; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @return mixed|null |
|
62 | + * @throws ClientExceptionInterface |
|
63 | + * @throws RedirectionExceptionInterface |
|
64 | + * @throws ServerExceptionInterface |
|
65 | + * @throws TransportExceptionInterface |
|
66 | + */ |
|
67 | + private function getComposerLockJson() |
|
68 | + { |
|
69 | + if ($this->package && !$this->package->isIsLocal()) { |
|
70 | + $response = $this->client->request("GET", $this->package->getProjectUrl().$this->package->getComposerLockUrl()); |
|
71 | + $composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null; |
|
72 | + } else { |
|
73 | + $composer_lock = file_get_contents('../composer.lock'); |
|
74 | + } |
|
75 | + |
|
76 | + if ($composer_lock) { |
|
77 | + return json_decode($composer_lock, true); |
|
78 | + } |
|
79 | + |
|
80 | + return null; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @param $package_name |
|
85 | + * @return mixed|null |
|
86 | + * @throws ClientExceptionInterface |
|
87 | + * @throws RedirectionExceptionInterface |
|
88 | + * @throws ServerExceptionInterface |
|
89 | + * @throws TransportExceptionInterface |
|
90 | + */ |
|
91 | + public function getPackage($package_name) |
|
92 | + { |
|
93 | + $composer_lock = $this->getComposerLockJson(); |
|
94 | + if ($composer_lock) { |
|
95 | + $packages = $composer_lock["packages"]; |
|
96 | + $key = array_search($package_name, array_column($packages, 'name')); |
|
97 | + |
|
98 | + if ($key) { |
|
99 | + return $packages[$key]; |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + $this->messages["composer_lock"] = "Composer lock not found at " . $this->package->getProjectUrl(); |
|
104 | + |
|
105 | + return null; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param $package_name |
|
110 | + * @return mixed|null |
|
111 | + */ |
|
112 | + public function getVersion($package_name) |
|
113 | + { |
|
114 | + return $this->getPackage($package_name) ? $this->getPackage($package_name)["version"] : null; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @param $package_name |
|
119 | + * @return DateTime|null |
|
120 | + * @throws Exception |
|
121 | + */ |
|
122 | + public function getVersionDate($package_name): ?DateTime |
|
123 | + { |
|
124 | + $string_date = $this->getPackage($package_name) ? explode("T", $this->getPackage($package_name)["time"])[0] : null; |
|
125 | + $version_date = null; |
|
126 | + |
|
127 | + if ($string_date) { |
|
128 | + $version_date = new DateTime($string_date); |
|
129 | + } |
|
130 | + |
|
131 | + return $version_date; |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * @param $package_name |
|
136 | + * @return false|int|string|null |
|
137 | + * @throws ClientExceptionInterface |
|
138 | + * @throws RedirectionExceptionInterface |
|
139 | + * @throws ServerExceptionInterface |
|
140 | + * @throws TransportExceptionInterface |
|
141 | + */ |
|
142 | + public function getLastPackagistVersion($package_name) |
|
143 | + { |
|
144 | + if (!strpos($package_name, "/")) { |
|
145 | + return false; |
|
146 | + } |
|
147 | + |
|
148 | + $packgist_url = "https://repo.packagist.org/p/".$package_name.".json"; |
|
149 | + |
|
150 | + $response = $this->client->request("GET", $packgist_url); |
|
151 | + |
|
152 | + if ($response->getStatusCode() == 200) { |
|
153 | + $content = json_decode($response->getContent(), true); |
|
154 | + if (is_array($content) && $content["packages"] && $content["packages"][$package_name]) { |
|
155 | + return array_key_first($content["packages"][$package_name]); |
|
156 | + } |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * @param $package_name |
|
162 | + * @throws Exception |
|
163 | + */ |
|
164 | + public function save($package_name) |
|
165 | + { |
|
166 | + $package = $this->em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]); |
|
167 | + |
|
168 | + if (!$package) { |
|
169 | + $package = new Package(); |
|
170 | + $package->setProjectName($package_name); |
|
171 | + $package->setPackageName($package_name); |
|
172 | + $package->setProjectUrl($package_name); |
|
173 | + $package->setCheckVersionUrl($package_name); |
|
174 | + } |
|
175 | + |
|
176 | + $package->setVersion($this->getVersion($package_name)); |
|
177 | + $package->setVersionDate($this->getVersionDate($package_name)); |
|
178 | + $package->setLastPackagistVersion($this->getLastPackagistVersion($package_name)); |
|
179 | + $package->setLastCheck(new DateTime()); |
|
180 | + |
|
181 | + $this->em->persist($package); |
|
182 | + $this->em->flush(); |
|
183 | + } |
|
184 | 184 | } |
@@ -16,148 +16,148 @@ |
||
16 | 16 | |
17 | 17 | class PackageController extends AbstractController |
18 | 18 | { |
19 | - /** |
|
20 | - * @Route("/packages/", name="ribsadmin_packages") |
|
21 | - * @param EntityManagerInterface $em |
|
22 | - * @return Response |
|
23 | - */ |
|
24 | - public function index(EntityManagerInterface $em): Response |
|
25 | - { |
|
26 | - $packages = $em->getRepository(Package::class)->findAll(); |
|
19 | + /** |
|
20 | + * @Route("/packages/", name="ribsadmin_packages") |
|
21 | + * @param EntityManagerInterface $em |
|
22 | + * @return Response |
|
23 | + */ |
|
24 | + public function index(EntityManagerInterface $em): Response |
|
25 | + { |
|
26 | + $packages = $em->getRepository(Package::class)->findAll(); |
|
27 | 27 | |
28 | - return $this->render("@RibsAdmin/packages/list.html.twig", ["packages" => $packages]); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * @Route("/packages/create/", name="ribsadmin_packages_create") |
|
33 | - * @Route("/packages/show/{guid}", name="ribsadmin_packages_show") |
|
34 | - * @Route("/packages/edit/{guid}", name="ribsadmin_packages_edit") |
|
35 | - * @param Request $request |
|
36 | - * @param EntityManagerInterface $em |
|
37 | - * @param string|null $guid |
|
38 | - * @return Response |
|
39 | - */ |
|
40 | - public function edit(Request $request, EntityManagerInterface $em, string $guid = null): Response |
|
41 | - { |
|
42 | - $disabled_form = strpos($request->get("_route"), "_show") ? true : false; |
|
43 | - if (!$guid) { |
|
44 | - $package = new Package(); |
|
45 | - $text = "created"; |
|
46 | - } else { |
|
47 | - $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
48 | - $text = "edited"; |
|
49 | - } |
|
50 | - |
|
51 | - $form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Package::class, $package, ["disabled" => $disabled_form]); |
|
52 | - $form->handleRequest($request); |
|
53 | - |
|
54 | - if ($form->isSubmitted() && $form->isValid()) { |
|
55 | - /** @var Package $data */ |
|
56 | - $data = $form->getData(); |
|
57 | - $em->persist($data); |
|
58 | - $em->flush(); |
|
59 | - $this->addFlash("success-flash", "Package " . $data->getProjectName() . " was " . $text); |
|
60 | - |
|
61 | - return $this->redirectToRoute("ribsadmin_packages"); |
|
62 | - } |
|
63 | - |
|
64 | - return $this->render("@RibsAdmin/packages/edit.html.twig", [ |
|
65 | - "form" => $form->createView(), |
|
66 | - "form_errors" => $form->getErrors(), |
|
67 | - "package" => $package |
|
68 | - ]); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @Route("/packages/delete/{guid}", name="ribsadmin_packages_delete") |
|
73 | - * @param EntityManagerInterface $em |
|
74 | - * @param string $guid |
|
75 | - * @return RedirectResponse |
|
76 | - */ |
|
77 | - public function delete(EntityManagerInterface $em, string $guid): RedirectResponse |
|
78 | - { |
|
79 | - $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
80 | - |
|
81 | - if ($package) { |
|
82 | - $em->remove($package); |
|
83 | - $em->flush(); |
|
84 | - $this->addFlash("success-flash", "The project package was deleted"); |
|
85 | - } else { |
|
86 | - $this->addFlash("error-flash", "The project package was not found"); |
|
87 | - } |
|
88 | - |
|
89 | - return $this->redirectToRoute("ribsadmin_packages"); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @Route("/packages/update/{guid}", name="ribsadmin_packages_update") |
|
94 | - * @param EntityManagerInterface $em |
|
95 | - * @param Version $version |
|
96 | - * @param string $guid |
|
97 | - * @return RedirectResponse |
|
98 | - * @throws Exception |
|
99 | - */ |
|
100 | - public function updatePackage(EntityManagerInterface $em, Version $version, string $guid): RedirectResponse |
|
101 | - { |
|
102 | - $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
103 | - |
|
104 | - if ($package) { |
|
105 | - $version->setPackageEntity($package); |
|
106 | - $version->save($package->getPackageName()); |
|
107 | - |
|
108 | - if ($version->getMessages()) { |
|
109 | - $message = "<ul>"; |
|
110 | - $message .= "<li>The project package was not well updated</li>"; |
|
111 | - foreach ($version->getMessages() as $version_message) { |
|
112 | - $message .= "<li>".$version_message."</li>"; |
|
113 | - } |
|
114 | - $message .= "</ul>"; |
|
115 | - |
|
116 | - $this->addFlash("info-flash", $message); |
|
117 | - } |
|
118 | - |
|
119 | - $this->addFlash("success-flash", "The project package was updated"); |
|
120 | - } else { |
|
121 | - $this->addFlash("error-flash", "The project package was not found"); |
|
122 | - } |
|
123 | - |
|
124 | - return $this->redirectToRoute("ribsadmin_packages"); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @Route("/packages/send-package/{package_name}", name="ribsadmin_packages_send", requirements={"package_name"=".+"}) |
|
129 | - * @param EntityManagerInterface $em |
|
130 | - * @param Version $version |
|
131 | - * @param string $package_name |
|
132 | - * @return mixed|null |
|
133 | - * @throws Exception |
|
134 | - */ |
|
135 | - public function sendPackageInformations(EntityManagerInterface $em, Version $version, string $package_name): JsonResponse |
|
136 | - { |
|
137 | - $package = $em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]); |
|
138 | - |
|
139 | - if ($package) { |
|
140 | - $version->setPackageEntity($package); |
|
141 | - } |
|
142 | - |
|
143 | - return new JsonResponse([ |
|
144 | - "package" => $version->getPackage($package_name), |
|
145 | - "package_date" => $version->getVersionDate($package_name) |
|
146 | - ]); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @Route("/packages/send-composer-lock/", name="ribsadmin_packages_send_composer_lock") |
|
151 | - * @return JsonResponse |
|
152 | - */ |
|
153 | - public function sendComposerJson(): JsonResponse |
|
154 | - { |
|
155 | - $composer_lock = file_get_contents('../composer.lock'); |
|
156 | - |
|
157 | - if ($composer_lock) { |
|
158 | - $composer_lock = json_decode($composer_lock); |
|
159 | - } |
|
160 | - |
|
161 | - return new JsonResponse($composer_lock); |
|
162 | - } |
|
28 | + return $this->render("@RibsAdmin/packages/list.html.twig", ["packages" => $packages]); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * @Route("/packages/create/", name="ribsadmin_packages_create") |
|
33 | + * @Route("/packages/show/{guid}", name="ribsadmin_packages_show") |
|
34 | + * @Route("/packages/edit/{guid}", name="ribsadmin_packages_edit") |
|
35 | + * @param Request $request |
|
36 | + * @param EntityManagerInterface $em |
|
37 | + * @param string|null $guid |
|
38 | + * @return Response |
|
39 | + */ |
|
40 | + public function edit(Request $request, EntityManagerInterface $em, string $guid = null): Response |
|
41 | + { |
|
42 | + $disabled_form = strpos($request->get("_route"), "_show") ? true : false; |
|
43 | + if (!$guid) { |
|
44 | + $package = new Package(); |
|
45 | + $text = "created"; |
|
46 | + } else { |
|
47 | + $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
48 | + $text = "edited"; |
|
49 | + } |
|
50 | + |
|
51 | + $form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Package::class, $package, ["disabled" => $disabled_form]); |
|
52 | + $form->handleRequest($request); |
|
53 | + |
|
54 | + if ($form->isSubmitted() && $form->isValid()) { |
|
55 | + /** @var Package $data */ |
|
56 | + $data = $form->getData(); |
|
57 | + $em->persist($data); |
|
58 | + $em->flush(); |
|
59 | + $this->addFlash("success-flash", "Package " . $data->getProjectName() . " was " . $text); |
|
60 | + |
|
61 | + return $this->redirectToRoute("ribsadmin_packages"); |
|
62 | + } |
|
63 | + |
|
64 | + return $this->render("@RibsAdmin/packages/edit.html.twig", [ |
|
65 | + "form" => $form->createView(), |
|
66 | + "form_errors" => $form->getErrors(), |
|
67 | + "package" => $package |
|
68 | + ]); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @Route("/packages/delete/{guid}", name="ribsadmin_packages_delete") |
|
73 | + * @param EntityManagerInterface $em |
|
74 | + * @param string $guid |
|
75 | + * @return RedirectResponse |
|
76 | + */ |
|
77 | + public function delete(EntityManagerInterface $em, string $guid): RedirectResponse |
|
78 | + { |
|
79 | + $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
80 | + |
|
81 | + if ($package) { |
|
82 | + $em->remove($package); |
|
83 | + $em->flush(); |
|
84 | + $this->addFlash("success-flash", "The project package was deleted"); |
|
85 | + } else { |
|
86 | + $this->addFlash("error-flash", "The project package was not found"); |
|
87 | + } |
|
88 | + |
|
89 | + return $this->redirectToRoute("ribsadmin_packages"); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @Route("/packages/update/{guid}", name="ribsadmin_packages_update") |
|
94 | + * @param EntityManagerInterface $em |
|
95 | + * @param Version $version |
|
96 | + * @param string $guid |
|
97 | + * @return RedirectResponse |
|
98 | + * @throws Exception |
|
99 | + */ |
|
100 | + public function updatePackage(EntityManagerInterface $em, Version $version, string $guid): RedirectResponse |
|
101 | + { |
|
102 | + $package = $em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
103 | + |
|
104 | + if ($package) { |
|
105 | + $version->setPackageEntity($package); |
|
106 | + $version->save($package->getPackageName()); |
|
107 | + |
|
108 | + if ($version->getMessages()) { |
|
109 | + $message = "<ul>"; |
|
110 | + $message .= "<li>The project package was not well updated</li>"; |
|
111 | + foreach ($version->getMessages() as $version_message) { |
|
112 | + $message .= "<li>".$version_message."</li>"; |
|
113 | + } |
|
114 | + $message .= "</ul>"; |
|
115 | + |
|
116 | + $this->addFlash("info-flash", $message); |
|
117 | + } |
|
118 | + |
|
119 | + $this->addFlash("success-flash", "The project package was updated"); |
|
120 | + } else { |
|
121 | + $this->addFlash("error-flash", "The project package was not found"); |
|
122 | + } |
|
123 | + |
|
124 | + return $this->redirectToRoute("ribsadmin_packages"); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @Route("/packages/send-package/{package_name}", name="ribsadmin_packages_send", requirements={"package_name"=".+"}) |
|
129 | + * @param EntityManagerInterface $em |
|
130 | + * @param Version $version |
|
131 | + * @param string $package_name |
|
132 | + * @return mixed|null |
|
133 | + * @throws Exception |
|
134 | + */ |
|
135 | + public function sendPackageInformations(EntityManagerInterface $em, Version $version, string $package_name): JsonResponse |
|
136 | + { |
|
137 | + $package = $em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]); |
|
138 | + |
|
139 | + if ($package) { |
|
140 | + $version->setPackageEntity($package); |
|
141 | + } |
|
142 | + |
|
143 | + return new JsonResponse([ |
|
144 | + "package" => $version->getPackage($package_name), |
|
145 | + "package_date" => $version->getVersionDate($package_name) |
|
146 | + ]); |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * @Route("/packages/send-composer-lock/", name="ribsadmin_packages_send_composer_lock") |
|
151 | + * @return JsonResponse |
|
152 | + */ |
|
153 | + public function sendComposerJson(): JsonResponse |
|
154 | + { |
|
155 | + $composer_lock = file_get_contents('../composer.lock'); |
|
156 | + |
|
157 | + if ($composer_lock) { |
|
158 | + $composer_lock = json_decode($composer_lock); |
|
159 | + } |
|
160 | + |
|
161 | + return new JsonResponse($composer_lock); |
|
162 | + } |
|
163 | 163 | } |