src/Domain/Entity/PressStatement.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Domain\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Delete;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use ApiPlatform\Metadata\Post;
  8. use ApiPlatform\Metadata\Put;
  9. use App\Domain\Entity\Behavior\Identifiable;
  10. use DateTime;
  11. use Gedmo\SoftDeleteable\Traits\SoftDeleteable;
  12. use Gedmo\Timestampable\Traits\Timestampable;
  13. /**
  14.  * Class PressKit
  15.  *
  16.  * @package App\Domain\Entity
  17.  */
  18. #[ApiResource(
  19.     operations            : [
  20.         new Delete(security"is_granted('ROLE_ADMIN')"),
  21.         new Get(),
  22.         new GetCollection(filters: ['press.search_filter''soft_delete_filter''press.order_filter']),
  23.         new Post(security"is_granted('ROLE_ADMIN')"),
  24.         new Put(security"is_granted('ROLE_ADMIN')"),
  25.     ],
  26.     normalizationContext  : ['groups' => ['press_statement_read']],
  27.     denormalizationContext: ['groups' => ['press_statement_write']]
  28. )]
  29. class PressStatement
  30. {
  31.     use Identifiable;
  32.     use SoftDeleteable;
  33.     use Timestampable;
  34.     /**
  35.      * @param Locale        $locale
  36.      * @param bool|null     $isVisible
  37.      * @param Media|null    $file
  38.      * @param DateTime|null $publicationDate
  39.      * @param string|null   $title
  40.      */
  41.     public function __construct(
  42.         public Locale $locale,
  43.         public ?bool $isVisible null,
  44.         public ?Media $file null,
  45.         public ?DateTime $publicationDate null,
  46.         public ?string $title null,
  47.     ) {}
  48.     public function getFormattedPublicationDate(): string
  49.     {
  50.         return $this->publicationDate->format('d/m/Y');
  51.     }
  52. }