src/Entity/File.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FileRepository;
  4. use App\Trait\SoftDeleteTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Uid\Uuid;
  11. #[ORM\Entity(repositoryClassFileRepository::class)]
  12. #[ORM\Index(fields: ['isDeleted'])]
  13. class File
  14. {
  15.     use SoftDeleteTrait;
  16.     #[ORM\Id]
  17.     #[ORM\Column(type'uuid'uniquetrue)]
  18.     #[Groups(['BASE'])]
  19.     private ?string $id null;
  20.     #[ORM\ManyToOne]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?Whitelabel $whitelabel null;
  23.     #[ORM\ManyToOne]
  24.     #[ORM\JoinColumn(nullablefalse)]
  25.     private ?User $creatorUser null;
  26.     #[ORM\Column(length255)]
  27.     private ?string $name null;
  28.     #[ORM\Column(length255)]
  29.     private ?string $path null;
  30.     #[ORM\Column]
  31.     private ?int $size null;
  32.     #[ORM\Column(length255)]
  33.     private ?string $md5 null;
  34.     #[ORM\Column(length255)]
  35.     private ?string $mimeType null;
  36.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  37.     private ?\DateTimeInterface $createDate null;
  38.     #[ORM\ManyToMany(targetEntityProperty::class, mappedBy'files')]
  39.     private Collection $properties;
  40.     #[ORM\ManyToMany(targetEntityMenu::class, mappedBy'files')]
  41.     private Collection $menus;
  42.     #[ORM\Column]
  43.     private ?int $sort null;
  44.     public function __construct()
  45.     {
  46.         $this->id Uuid::v4();
  47.         $this->properties = new ArrayCollection();
  48.         $this->menus = new ArrayCollection();
  49.     }
  50.     public function __toString()
  51.     {
  52.         return $this->getName();
  53.     }
  54.     public function getId(): ?string
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getWhitelabel(): ?Whitelabel
  59.     {
  60.         return $this->whitelabel;
  61.     }
  62.     public function setWhitelabel(?Whitelabel $whitelabel): static
  63.     {
  64.         $this->whitelabel $whitelabel;
  65.         return $this;
  66.     }
  67.     public function getCreatorUser(): ?User
  68.     {
  69.         return $this->creatorUser;
  70.     }
  71.     public function setCreatorUser(?User $creatorUser): static
  72.     {
  73.         $this->creatorUser $creatorUser;
  74.         return $this;
  75.     }
  76.     public function getName(): ?string
  77.     {
  78.         return $this->name;
  79.     }
  80.     public function setName(string $name): static
  81.     {
  82.         $this->name $name;
  83.         return $this;
  84.     }
  85.     public function getPath(): ?string
  86.     {
  87.         return $this->path;
  88.     }
  89.     public function setPath(string $path): static
  90.     {
  91.         $this->path $path;
  92.         return $this;
  93.     }
  94.     public function getSize(): ?int
  95.     {
  96.         return $this->size;
  97.     }
  98.     public function setSize(int $size): static
  99.     {
  100.         $this->size $size;
  101.         return $this;
  102.     }
  103.     public function getMd5(): ?string
  104.     {
  105.         return $this->md5;
  106.     }
  107.     public function setMd5(string $md5): static
  108.     {
  109.         $this->md5 $md5;
  110.         return $this;
  111.     }
  112.     public function getMimeType(): ?string
  113.     {
  114.         return $this->mimeType;
  115.     }
  116.     public function setMimeType(string $mimeType): static
  117.     {
  118.         $this->mimeType $mimeType;
  119.         return $this;
  120.     }
  121.     public function getCreateDate(): ?\DateTimeInterface
  122.     {
  123.         return $this->createDate;
  124.     }
  125.     public function setCreateDate(\DateTimeInterface $createDate): static
  126.     {
  127.         $this->createDate $createDate;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return Collection<int, Property>
  132.      */
  133.     public function getProperties(): Collection
  134.     {
  135.         return $this->properties;
  136.     }
  137.     public function addProperty(Property $property): static
  138.     {
  139.         if (!$this->properties->contains($property)) {
  140.             $this->properties->add($property);
  141.             $property->addFile($this);
  142.         }
  143.         return $this;
  144.     }
  145.     public function removeProperty(Property $property): static
  146.     {
  147.         if ($this->properties->removeElement($property)) {
  148.             $property->removeFile($this);
  149.         }
  150.         return $this;
  151.     }
  152.     /**
  153.      * @return Collection<int, Menu>
  154.      */
  155.     public function getMenus(): Collection
  156.     {
  157.         return $this->menus;
  158.     }
  159.     public function addMenu(Menu $menu): static
  160.     {
  161.         if (!$this->menus->contains($menu)) {
  162.             $this->menus->add($menu);
  163.             $menu->addFile($this);
  164.         }
  165.         return $this;
  166.     }
  167.     public function removeMenu(Menu $menu): static
  168.     {
  169.         if ($this->menus->removeElement($menu)) {
  170.             $menu->removeFile($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function getSort(): ?int
  175.     {
  176.         return $this->sort;
  177.     }
  178.     public function setSort(int $sort): static
  179.     {
  180.         $this->sort $sort;
  181.         return $this;
  182.     }
  183. }