src/Entity/Document.php line 48

Open in your IDE?
  1. <?php
  2. // @deprecated 
  3. declare(strict_types=1);
  4. namespace App\Entity;
  5. use ApiPlatform\Core\Annotation\ApiProperty;
  6. use ApiPlatform\Core\Annotation\ApiResource;
  7. use App\Trait\TimestampableEntity;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Ramsey\Uuid\Uuid;
  12. use Ramsey\Uuid\UuidInterface;
  13. /**
  14.  * A media object, such as an image, video, audio, or text object embedded in a web page or a downloadable dataset i.e. DataDownload. Note that a creative work may have many media objects associated with it on the same web page. For example, a page about a single song (MusicRecording) may have a music video (VideoObject), and a high and low bandwidth audio stream (2 AudioObject's).
  15.  *
  16.  * @see https://schema.org/MediaObject
  17.  *
  18.  * @author Jordi Fernandes Alves <jfadev@gmail.com>
  19.  */
  20. #[ORM\Entity]
  21. #[ApiResource(
  22.     iri'Document',
  23.     itemOperations: [
  24.         'get' => ['normalization_context' => ['groups' => 'document:item:get''enable_max_depth' => true]],
  25.         'put' => [
  26.             'normalization_context' => ['groups' => 'document:item:put''enable_max_depth' => true],
  27.             'denormalization_context' => ['groups' => 'document:item:put''enable_max_depth' => true],
  28.         ],
  29.         'delete' => [],
  30.     ],
  31.     collectionOperations: [
  32.         'get' => [
  33.             'normalization_context' => [
  34.                 'groups' => ['document:collection:get''createdAt'],
  35.                 'enable_max_depth' => true,
  36.             ],
  37.         ],
  38.         'post' => [
  39.             'normalization_context' => ['groups' => 'document:collection:post''enable_max_depth' => true],
  40.             'denormalization_context' => ['groups' => 'document:collection:post''enable_max_depth' => true],
  41.         ],
  42.     ],
  43. )]
  44. class Document
  45. {
  46.     use TimestampableEntity;
  47.     
  48.     #[ORM\Id]
  49.     #[ORM\GeneratedValue(strategy'NONE')]
  50.     #[ORM\Column(type'uuid'uniquetrue)]
  51.     #[ApiProperty(iri'https://schema.org/identifier')]
  52.     #[Groups(['document:item:get''document:item:put''document:collection:get''document:collection:post'])]
  53.     private ?int $id null;
  54.     /**
  55.      * Date (including time if available) when this media object was uploaded to this site.
  56.      *
  57.      * @see https://schema.org/uploadDate
  58.      */
  59.     #[ORM\Column(type'datetime'nullablefalse)]
  60.     #[ApiProperty(iri'https://schema.org/uploadDate')]
  61.     #[Assert\Type(\DateTimeInterface::class)]
  62.     #[Groups(['document:item:get''document:item:put''document:collection:get''document:collection:post'])]
  63.     private ?\DateTimeInterface $uploadDate null;
  64.     public function __construct()
  65.     {
  66.         $this->id Uuid::uuid4();
  67.     }
  68.     public function getId(): ?UuidInterface
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function setUploadDate(?\DateTimeInterface $uploadDate): void
  73.     {
  74.         $this->uploadDate $uploadDate;
  75.     }
  76.     public function getUploadDate(): ?\DateTimeInterface
  77.     {
  78.         return $this->uploadDate;
  79.     }
  80. }