6 Commits

Author SHA1 Message Date
gitea-actions
6458a1b35c chore: bump version to v0.1.16
All checks were successful
Auto Tag Develop / tag (push) Successful in 5s
Build & Push Docker Image / build (push) Successful in 17s
2026-04-06 14:50:18 +00:00
de81b55867 Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
2026-04-06 16:50:12 +02:00
a3cd1f6b74 fix : use custom EnvironmentCreateProcessor to properly add environments
API Platform's default sub-resource POST was replacing instead of adding.
Custom processor with read:false + Link + manual persist fixes this.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 16:49:44 +02:00
gitea-actions
5eb4921c60 chore: bump version to v0.1.15
All checks were successful
Auto Tag Develop / tag (push) Successful in 5s
Build & Push Docker Image / build (push) Successful in 17s
2026-04-06 14:44:06 +00:00
c7e32c74b6 Merge remote-tracking branch 'origin/develop' into develop
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
2026-04-06 16:43:58 +02:00
e9850fdb2e fix : correct Link uriVariables for environment POST endpoint
Use toProperty + identifiers instead of fromProperty to resolve
application slug correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 16:43:26 +02:00
3 changed files with 49 additions and 2 deletions

View File

@@ -1,2 +1,2 @@
parameters:
app.version: '0.1.14'
app.version: '0.1.16'

View File

@@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use App\Repository\EnvironmentRepository;
use App\State\EnvironmentCreateProcessor;
use App\State\MaintenanceToggleProcessor;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@@ -21,9 +22,11 @@ use Symfony\Component\Serializer\Attribute\Groups;
new Post(
uriTemplate: '/applications/{slug}/environments',
uriVariables: [
'slug' => new Link(fromClass: Application::class, fromProperty: 'environments'),
'slug' => new Link(toProperty: 'application', fromClass: Application::class, identifiers: ['slug']),
],
read: false,
security: "is_granted('ROLE_ADMIN')",
processor: EnvironmentCreateProcessor::class,
),
new Patch(
security: "is_granted('ROLE_ADMIN')",

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace App\State;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use App\Entity\Environment;
use App\Repository\ApplicationRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
final readonly class EnvironmentCreateProcessor implements ProcessorInterface
{
public function __construct(
private ApplicationRepository $applicationRepository,
private EntityManagerInterface $entityManager,
) {}
/**
* @param Environment $data
*/
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): Environment
{
$slug = $uriVariables['slug']
?? $context['request']?->attributes->get('slug')
?? $context['request']?->attributes->get('_route_params')['slug']
?? '';
$application = $this->applicationRepository->findOneBy(['slug' => $slug]);
if (null === $application) {
throw new NotFoundHttpException(sprintf('Application "%s" not found.', $slug));
}
$data->setApplication($application);
$this->entityManager->persist($data);
$this->entityManager->flush();
return $data;
}
}