feat: ajout de la gestion des sources de contenu avec des commandes et des gestionnaires pour l'importation, la mise à jour et l'exportation, ainsi que la création des ressources API correspondantes.
This commit is contained in:
parent
ebcca466a9
commit
32b4e4fbb2
@@ -0,0 +1,49 @@
|
||||
<?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 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}',
|
||||
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,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user