1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PiouPiou\RibsAdminBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
6
|
|
|
use Exception; |
7
|
|
|
use PiouPiou\RibsAdminBundle\Entity\Package; |
8
|
|
|
use PiouPiou\RibsAdminBundle\Service\Version; |
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
10
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
11
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
12
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
13
|
|
|
|
14
|
|
|
class PackagesDistController extends AbstractController |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @Route("/packages/send-package/{package_name}", name="ribsadmin_packages_send", requirements={"package_name"=".+"}) |
18
|
|
|
* @param EntityManagerInterface $em |
19
|
|
|
* @param Version $version |
20
|
|
|
* @param string $package_name |
21
|
|
|
* @return mixed|null |
22
|
|
|
* @throws Exception |
23
|
|
|
*/ |
24
|
|
|
public function sendPackageInformations(EntityManagerInterface $em, Version $version, string $package_name): JsonResponse |
25
|
|
|
{ |
26
|
|
|
$package = $em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]); |
27
|
|
|
|
28
|
|
|
if ($package) { |
29
|
|
|
$version->setPackageEntity($package); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
return new JsonResponse([ |
33
|
|
|
"package" => $version->getPackage(), |
34
|
|
|
"package_date" => $version->getVersionDate() |
35
|
|
|
]); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @Route("/packages/send-composer-lock/", name="ribsadmin_packages_send_composer_lock") |
40
|
|
|
* @return JsonResponse |
41
|
|
|
*/ |
42
|
|
|
public function sendComposerJson(): JsonResponse |
43
|
|
|
{ |
44
|
|
|
$composer_lock = file_get_contents('../composer.lock'); |
45
|
|
|
|
46
|
|
|
if ($composer_lock) { |
47
|
|
|
$composer_lock = json_decode($composer_lock); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return new JsonResponse($composer_lock); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @Route("/packages/send-token/", name="ribsadmin_packages_send_token") |
55
|
|
|
* @param ParameterBagInterface $parameter |
56
|
|
|
* @return JsonResponse |
57
|
|
|
*/ |
58
|
|
|
public function sendToken(ParameterBagInterface $parameter): JsonResponse |
59
|
|
|
{ |
60
|
|
|
return new JsonResponse([ |
61
|
|
|
"token" => $parameter->get("ribs_admin.packages_token") |
62
|
|
|
]); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|