<?php
declare(strict_types=1);
namespace App\Domain\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\Application\ApiResources\State\Provider\GetPartnerProvider;
use App\Domain\Entity\Behavior\Identifiable;
use Gedmo\SoftDeleteable\Traits\SoftDeleteable;
use Gedmo\Timestampable\Traits\Timestampable;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[UniqueEntity(fields: ['slug'], message: 'There is already a partner with that slug')]
#[ApiResource(
operations: [
new Delete(security: "is_granted('ROLE_ADMIN')"),
new Get(
requirements: [
'uuid' => '^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$',
],
),
new Get(
uriTemplate: '/partners/slug',
name: 'get_partner_by_slug',
provider: GetPartnerProvider::class,
),
new GetCollection(filters: ['partner.search_filter']),
new GetCollection(
uriTemplate: '/partners/list',
filters: ['partner.search_filter'],
normalizationContext: ['groups' => ['partners_list_read']],
),
new Post(security: "is_granted('ROLE_ADMIN')"),
new Put(security: "is_granted('ROLE_ADMIN')"),
],
normalizationContext: ['groups' => ['partner_read']],
denormalizationContext: ['groups' => ['partner_write']],
order: ['displayOrder' => 'asc']
)]
class Partner
{
use Identifiable;
use SoftDeleteable;
use Timestampable;
/**
* @param string|null $description
* @param string|null $more
* @param string|null $introduction
* @param Locale|null $locale
* @param Media|null $logo
* @param string|null $slug
* @param string|null $title
* @param string|null $subTitle
* @param int $isSpecific
* @param string|null $url
* @param string|null $popupTitle
* @param string|null $popupDescription
* @param string|null $popupLabel
* @param string|null $popupError
* @param string|null $legals
* @param int|null $displayOrder
* @param bool $visible
* @param bool $isPremium
* @param string|null $premiumTitle
* @param string|null $premiumDescription
*/
public function __construct(
public ?string $description = null,
public ?string $more = null,
public ?string $introduction = null,
public ?Locale $locale = null,
public ?Media $logo = null,
public ?string $slug = null,
public ?string $title = null,
public ?string $subTitle = null,
public int $isSpecific = 0,
public ?string $url = null,
public ?string $popupTitle = null,
public ?string $popupDescription = null,
public ?string $popupLabel = null,
public ?string $popupError = null,
public ?string $legals = null,
public ?int $displayOrder = null,
public bool $visible = true,
public bool $isPremium = true,
public ?string $premiumTitle = null,
public ?string $premiumDescription = null,
) {}
}