feat: implement Plan 2 — Article Management API
- 6 new domain repository interfaces (StoragePath, ArticlePhoto, AttributeValue, ChannelField, ArticleTypePlatformConfig, AttributeMapping)
- 6 Doctrine repository implementations
- StorageManager with multi-path quota-aware file storage (LocalStorageManager)
- Application services: ArticleTypeService, ArticleService, ArticleValidator, PhotoService, PlatformService, MappingService
- REST controllers: ArticleType, Article, Photo, Platform, Mapping (all under /api prefix)
- inventory_number sequence migration
- 22 unit tests passing, PHPStan level 9 clean, CS Fixer clean
- Fixed phpdoc_to_comment CS Fixer rule (disabled) to preserve @var type annotations
- Fixed PHPStan: User::getUserIdentifier non-empty-string, AIPipelineJob nullable missingFields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:19:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Infrastructure\Http\Controller\Api;
|
|
|
|
|
|
|
|
|
|
use App\Application\Channel\PlatformService;
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
|
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
|
|
2026-05-17 22:44:11 +00:00
|
|
|
#[Route('/api/platforms', name: 'api_platforms_')]
|
feat: implement Plan 2 — Article Management API
- 6 new domain repository interfaces (StoragePath, ArticlePhoto, AttributeValue, ChannelField, ArticleTypePlatformConfig, AttributeMapping)
- 6 Doctrine repository implementations
- StorageManager with multi-path quota-aware file storage (LocalStorageManager)
- Application services: ArticleTypeService, ArticleService, ArticleValidator, PhotoService, PlatformService, MappingService
- REST controllers: ArticleType, Article, Photo, Platform, Mapping (all under /api prefix)
- inventory_number sequence migration
- 22 unit tests passing, PHPStan level 9 clean, CS Fixer clean
- Fixed phpdoc_to_comment CS Fixer rule (disabled) to preserve @var type annotations
- Fixed PHPStan: User::getUserIdentifier non-empty-string, AIPipelineJob nullable missingFields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:19:20 +00:00
|
|
|
final class PlatformController extends AbstractController
|
|
|
|
|
{
|
|
|
|
|
public function __construct(private readonly PlatformService $service)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('', name: 'list', methods: ['GET'])]
|
|
|
|
|
public function list(): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
return $this->json(array_map(static fn ($p) => [
|
|
|
|
|
'id' => $p->getId()->toRfc4122(),
|
|
|
|
|
'type' => $p->getType(),
|
|
|
|
|
'label' => $p->getLabel(),
|
|
|
|
|
], $this->service->findAll()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('', name: 'create', methods: ['POST'])]
|
|
|
|
|
public function create(Request $request): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
$data = $request->toArray();
|
|
|
|
|
if (empty($data['type']) || empty($data['label'])) {
|
|
|
|
|
return $this->json(['error' => 'type and label are required'], Response::HTTP_BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$platform = $this->service->create($data['type'], $data['label'], $data['config'] ?? []);
|
|
|
|
|
|
|
|
|
|
return $this->json(['id' => $platform->getId()->toRfc4122(), 'type' => $platform->getType()], Response::HTTP_CREATED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/{id}/channel-fields', name: 'list_fields', methods: ['GET'])]
|
|
|
|
|
public function listFields(string $id): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
$fields = $this->service->findChannelFields(Uuid::fromString($id));
|
|
|
|
|
|
|
|
|
|
return $this->json(array_map(static fn ($f) => [
|
|
|
|
|
'id' => $f->getId()->toRfc4122(),
|
|
|
|
|
'label' => $f->getLabel(),
|
|
|
|
|
'path' => $f->getPath(),
|
|
|
|
|
], $fields));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/{id}/channel-fields', name: 'add_field', methods: ['POST'])]
|
|
|
|
|
public function addField(string $id, Request $request): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
$data = $request->toArray();
|
|
|
|
|
if (empty($data['label']) || empty($data['path'])) {
|
|
|
|
|
return $this->json(['error' => 'label and path are required'], Response::HTTP_BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$field = $this->service->addChannelField(Uuid::fromString($id), $data['label'], $data['path']);
|
|
|
|
|
} catch (\DomainException $e) {
|
|
|
|
|
return $this->json(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->json(['id' => $field->getId()->toRfc4122(), 'label' => $field->getLabel()], Response::HTTP_CREATED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/channel-fields/{fieldId}', name: 'remove_field', methods: ['DELETE'])]
|
|
|
|
|
public function removeField(string $fieldId): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$this->service->removeChannelField(Uuid::fromString($fieldId));
|
|
|
|
|
} catch (\DomainException $e) {
|
|
|
|
|
return $this->json(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->json(null, Response::HTTP_NO_CONTENT);
|
|
|
|
|
}
|
|
|
|
|
}
|