- Ajouter testSlug, testChapterNumber, baseUrl sur ContentSource (entité, domain model, migration) - Exposer ces champs dans les Resources, Processors, Providers et Mapper - Mettre à jour store Pinia, repository API et composants Vue (form, card, liste)
51 lines
2.0 KiB
PHP
51 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Setting\Infrastructure\ApiPlatform\Resource;
|
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use ApiPlatform\Metadata\Post;
|
|
use ApiPlatform\Metadata\Put;
|
|
use App\Domain\Setting\Infrastructure\ApiPlatform\State\Processor\UpsertContentSourceStateProcessor;
|
|
use App\Domain\Setting\Infrastructure\ApiPlatform\State\Provider\GetContentSourceStateProvider;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
#[ApiResource(
|
|
shortName: 'ContentSource',
|
|
operations: [
|
|
new Post(
|
|
uriTemplate: '/content-sources',
|
|
processor: UpsertContentSourceStateProcessor::class,
|
|
input: UpsertContentSourceResource::class,
|
|
status: 201,
|
|
description: 'Crée une nouvelle source de contenu'
|
|
),
|
|
new Put(
|
|
uriTemplate: '/content-sources/{id}',
|
|
provider: GetContentSourceStateProvider::class,
|
|
processor: UpsertContentSourceStateProcessor::class,
|
|
input: UpsertContentSourceResource::class,
|
|
description: 'Met à jour une source de contenu existante'
|
|
)
|
|
]
|
|
)]
|
|
class UpsertContentSourceResource
|
|
{
|
|
public function __construct(
|
|
public readonly ?int $id = null,
|
|
#[Assert\NotBlank(message: 'L\'URL de base est obligatoire')]
|
|
#[Assert\Url(message: 'L\'URL de base doit être une URL valide')]
|
|
public readonly string $baseUrl = '',
|
|
#[Assert\NotBlank(message: 'Le format d\'URL de chapitre est obligatoire')]
|
|
public readonly string $chapterUrlFormat = '',
|
|
#[Assert\NotBlank(message: 'Le type de scraping est obligatoire')]
|
|
#[Assert\Choice(choices: ['html', 'javascript'], message: 'Le type de scraping doit être html ou javascript')]
|
|
public readonly string $scrapingType = '',
|
|
public readonly ?string $imageSelector = null,
|
|
public readonly ?string $nextPageSelector = null,
|
|
public readonly ?string $chapterSelector = null,
|
|
public readonly ?string $testSlug = null,
|
|
public readonly ?float $testChapterNumber = null,
|
|
) {
|
|
}
|
|
}
|