src/Entity/File/File.php line 24

  1. <?php
  2. namespace App\Entity\File;
  3. use ApiPlatform\Metadata\ApiProperty;
  4. use App\Entity\Common;
  5. use App\Entity\Identity\User;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. #[ORM\Table(name'file')]
  10. #[ORM\Index(columns: ['created_by'], name'file_created_by_idx')]
  11. #[ORM\Index(columns: ['updated_by'], name'file_updated_by_idx')]
  12. #[ORM\UniqueConstraint(name'file_slug_key'columns: ['slug'])]
  13. #[ORM\UniqueConstraint(name'file_path_key'columns: ['path'])]
  14. #[ORM\InheritanceType('SINGLE_TABLE')]
  15. #[ORM\DiscriminatorColumn(name'file_type')]
  16. #[ORM\DiscriminatorMap([
  17.     'PARSABLE' => Parsable::class,
  18.     'UPLOADED' => Upload::class,
  19. ])]
  20. #[ORM\Entity]
  21. abstract class File
  22. {
  23.     use Common\Blameable;
  24.     use Common\Trackable;
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  27.     #[ORM\SequenceGenerator(sequenceName'file_id_seq')]
  28.     #[ORM\Column(typeTypes::INTEGER)]
  29.     #[ApiProperty(identifierfalse)]
  30.     protected ?int $id null;
  31.     #[Gedmo\Slug(fields: ['name'])]
  32.     #[ORM\Column(typeTypes::STRING)]
  33.     #[ApiProperty(identifiertrue)]
  34.     protected ?string $slug null;
  35.     #[ORM\Column(typeTypes::STRING)]
  36.     protected ?string $name null;
  37.     #[ORM\Column(typeTypes::STRING)]
  38.     protected ?string $originalName null;
  39.     #[ORM\Column(typeTypes::STRING)]
  40.     protected ?string $path null;
  41.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  42.     protected ?string $description null;
  43.     #[ORM\Column(typeTypes::STRING)]
  44.     protected ?string $mimeType null;
  45.     #[ORM\Column(typeTypes::INTEGER)]
  46.     protected ?int $size null;
  47.     /*
  48.      * Override Blameable User as this field could be null
  49.      */
  50.     #[Gedmo\Blameable(on'create')]
  51.     #[ORM\ManyToOne(targetEntityUser::class)]
  52.     #[ORM\JoinColumn(name'created_by'nullabletrue)]
  53.     protected ?User $createdBy null;
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getSlug(): ?string
  59.     {
  60.         return $this->slug;
  61.     }
  62.     public function setSlug(string $slug): self
  63.     {
  64.         $this->slug $slug;
  65.         return $this;
  66.     }
  67.     public function getName(): ?string
  68.     {
  69.         return $this->name;
  70.     }
  71.     public function setName(?string $name): self
  72.     {
  73.         $this->name $name;
  74.         return $this;
  75.     }
  76.     public function getOriginalName(): ?string
  77.     {
  78.         return $this->originalName;
  79.     }
  80.     public function setOriginalName(?string $originalName): self
  81.     {
  82.         $this->originalName $originalName;
  83.         return $this;
  84.     }
  85.     public function getPath(): ?string
  86.     {
  87.         return $this->path;
  88.     }
  89.     public function setPath(string $path): self
  90.     {
  91.         $this->path $path;
  92.         return $this;
  93.     }
  94.     public function getDescription(): ?string
  95.     {
  96.         return $this->description;
  97.     }
  98.     public function setDescription(?string $description): self
  99.     {
  100.         $this->description $description;
  101.         return $this;
  102.     }
  103.     public function getMimeType(): ?string
  104.     {
  105.         return $this->mimeType;
  106.     }
  107.     public function setMimeType(string $mimeType): self
  108.     {
  109.         $this->mimeType $mimeType;
  110.         return $this;
  111.     }
  112.     public function getSize(): ?int
  113.     {
  114.         return $this->size;
  115.     }
  116.     public function setSize(int $size): self
  117.     {
  118.         $this->size $size;
  119.         return $this;
  120.     }
  121. }