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>
This commit is contained in:
@@ -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;
|
||||
@@ -23,7 +24,9 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
uriVariables: [
|
||||
'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')",
|
||||
|
||||
Reference in New Issue
Block a user