refactor : remove old YAML-based application config system

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-06 13:32:17 +02:00
parent bf62ccf9e9
commit 467c2fcef8
5 changed files with 0 additions and 119 deletions

6
.env
View File

@@ -43,9 +43,3 @@ DEFAULT_URI=http://localhost
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###
###> malio/maintenance ###
SIRH_MAINTENANCE_PATH=/var/www/maintenance/sirh/maintenance.on
LESSTIME_MAINTENANCE_PATH=/var/www/maintenance/lesstime/maintenance.on
INVENTORY_MAINTENANCE_PATH=/var/www/maintenance/inventory/maintenance.on
###< malio/maintenance ###

View File

@@ -1,5 +0,0 @@
parameters:
app.managed_applications:
- { name: 'SIRH', slug: 'sirh', maintenance_path: '%env(SIRH_MAINTENANCE_PATH)%' }
- { name: 'Lesstime', slug: 'lesstime', maintenance_path: '%env(LESSTIME_MAINTENANCE_PATH)%' }
- { name: 'Inventory', slug: 'inventory', maintenance_path: '%env(INVENTORY_MAINTENANCE_PATH)%' }

View File

@@ -4,7 +4,6 @@ parameters:
imports:
- { resource: version.yaml }
- { resource: applications.yaml }
services:
# default configuration for services in *this* file

View File

@@ -1,51 +0,0 @@
<?php
declare(strict_types=1);
namespace App\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use App\State\ManagedApplicationProvider;
use App\State\MaintenanceToggleProcessor;
use Symfony\Component\Serializer\Attribute\Groups;
#[ApiResource(
operations: [
new GetCollection(
uriTemplate: '/applications',
normalizationContext: ['groups' => ['app:read']],
security: "is_granted('ROLE_ADMIN')",
provider: ManagedApplicationProvider::class,
),
new Get(
uriTemplate: '/applications/{slug}',
normalizationContext: ['groups' => ['app:read']],
security: "is_granted('ROLE_ADMIN')",
provider: ManagedApplicationProvider::class,
),
new Post(
uriTemplate: '/applications/{slug}/maintenance',
normalizationContext: ['groups' => ['app:read']],
denormalizationContext: ['groups' => ['app:write']],
security: "is_granted('ROLE_ADMIN')",
provider: ManagedApplicationProvider::class,
processor: MaintenanceToggleProcessor::class,
),
],
)]
final class ManagedApplication
{
#[ApiProperty(identifier: true)]
#[Groups(['app:read'])]
public string $slug = '';
#[Groups(['app:read'])]
public string $name = '';
#[Groups(['app:read', 'app:write'])]
public bool $maintenance = false;
}

View File

@@ -1,56 +0,0 @@
<?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;
}
}