<?php
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\Domain\Entity\Behavior\Identifiable;
use DateTime;
use Gedmo\SoftDeleteable\Traits\SoftDeleteable;
use Gedmo\Timestampable\Traits\Timestampable;
/**
* Class PressKit
*
* @package App\Domain\Entity
*/
#[ApiResource(
operations : [
new Delete(security: "is_granted('ROLE_ADMIN')"),
new Get(),
new GetCollection(filters: ['press.search_filter', 'soft_delete_filter', 'press.order_filter']),
new Post(security: "is_granted('ROLE_ADMIN')"),
new Put(security: "is_granted('ROLE_ADMIN')"),
],
normalizationContext : ['groups' => ['press_statement_read']],
denormalizationContext: ['groups' => ['press_statement_write']]
)]
class PressStatement
{
use Identifiable;
use SoftDeleteable;
use Timestampable;
/**
* @param Locale $locale
* @param bool|null $isVisible
* @param Media|null $file
* @param DateTime|null $publicationDate
* @param string|null $title
*/
public function __construct(
public Locale $locale,
public ?bool $isVisible = null,
public ?Media $file = null,
public ?DateTime $publicationDate = null,
public ?string $title = null,
) {}
public function getFormattedPublicationDate(): string
{
return $this->publicationDate->format('d/m/Y');
}
}