feat(central) : ajoute le pilotage de maintenance et le deploiement prod

This commit is contained in:
2026-04-03 11:34:48 +02:00
parent 8e59f59679
commit 4234efdb50
45 changed files with 29298 additions and 30 deletions

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace App\State;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use App\ApiResource\ManagedApplication;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
final readonly class ManagedApplicationProvider implements ProviderInterface
{
/**
* @param list<array{name: string, slug: string, maintenance_path: string}> $managedApplications
*/
public function __construct(
#[Autowire('%app.managed_applications%')]
private array $managedApplications,
) {}
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ManagedApplication|array
{
if ($operation instanceof GetCollection) {
return array_map(
fn (array $app) => $this->buildDto($app),
$this->managedApplications,
);
}
$slug = $uriVariables['slug'] ?? '';
foreach ($this->managedApplications as $app) {
if ($app['slug'] === $slug) {
return $this->buildDto($app);
}
}
throw new NotFoundHttpException(sprintf('Application "%s" not found.', $slug));
}
/**
* @param array{name: string, slug: string, maintenance_path: string} $app
*/
private function buildDto(array $app): ManagedApplication
{
$dto = new ManagedApplication();
$dto->slug = $app['slug'];
$dto->name = $app['name'];
$dto->maintenance = file_exists($app['maintenance_path']);
return $dto;
}
}