src/Entity/DocumentModel.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DocumentModelRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassDocumentModelRepository::class)]
  8. #[ORM\HasLifecycleCallbacks]
  9. class DocumentModel
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[ORM\Column(type'string'length100)]
  16.     private $name;
  17.     #[ORM\Column(type'boolean')]
  18.     private $isForMinor true;
  19.     #[ORM\Column(type'boolean')]
  20.     private $isForAdult true;
  21.     #[ORM\Column(type'boolean')]
  22.     private $isPhysical false;
  23.     #[ORM\Column(type'boolean')]
  24.     private $isCroppable false;
  25.     #[ORM\Column(type'json'nullabletrue)]
  26.     private $allowedMimeTypes = ['image/*''application/pdf'];
  27.     #[ORM\OneToOne(targetEntityFile::class, cascade: ['persist''remove'])]
  28.     private $file;
  29.     #[ORM\ManyToOne(targetEntitySeason::class, inversedBy'documentModels')]
  30.     #[ORM\JoinColumn(nullablefalse)]
  31.     private $season;
  32.     #[ORM\ManyToMany(targetEntityself::class, inversedBy'children')]
  33.     #[ORM\JoinTable(name'document_model_link')]
  34.     #[ORM\JoinColumn('parent_id''id')]
  35.     #[ORM\InverseJoinColumn('child_id''id')]
  36.     private $parents;
  37.     #[ORM\ManyToMany(targetEntityself::class, mappedBy'parents')]
  38.     private $children;
  39.     #[ORM\OneToMany(mappedBy'model'targetEntityDocument::class)]
  40.     private $documents;
  41.     #[ORM\ManyToOne(targetEntityDiscountModel::class, inversedBy'documentModels')]
  42.     private $discountModel;
  43.     #[ORM\Column(type'text'nullabletrue)]
  44.     private $description;
  45.     private $linkedDocuments;
  46.     #[ORM\Column(length255nullabletrue)]
  47.     private ?string $slug null;
  48.     #[ORM\Column(nullabletrue)]
  49.     private ?bool $adminOnly null;
  50.     public function __construct()
  51.     {
  52.         $this->parents = new ArrayCollection();
  53.         $this->children = new ArrayCollection();
  54.         $this->documents = new ArrayCollection();
  55.         $this->linkedDocuments = new ArrayCollection();
  56.     }
  57.     public function __toString(): string
  58.     {
  59.         return $this->getName();
  60.     }
  61.     public function __clone()
  62.     {
  63.         $this->id null;
  64.         $this->parents = new ArrayCollection();
  65.         $this->children = new ArrayCollection();
  66.         $this->documents = new ArrayCollection();
  67.         $this->linkedDocuments = new ArrayCollection();
  68.     }
  69.     #[ORM\PostLoad]
  70.     public function postLoad()
  71.     {
  72.         $this->linkedDocuments = new ArrayCollection();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getName(): ?string
  79.     {
  80.         return $this->name;
  81.     }
  82.     public function setName(string $name): self
  83.     {
  84.         $this->name $name;
  85.         return $this;
  86.     }
  87.     public function getIsForMinor(): ?bool
  88.     {
  89.         return $this->isForMinor;
  90.     }
  91.     public function setIsForMinor(bool $isForMinor): self
  92.     {
  93.         $this->isForMinor $isForMinor;
  94.         return $this;
  95.     }
  96.     public function getIsForAdult(): ?bool
  97.     {
  98.         return $this->isForAdult;
  99.     }
  100.     public function setIsForAdult(bool $isForAdult): self
  101.     {
  102.         $this->isForAdult $isForAdult;
  103.         return $this;
  104.     }
  105.     public function getIsPhysical(): ?bool
  106.     {
  107.         return $this->isPhysical;
  108.     }
  109.     public function setIsPhysical(bool $isPhysical): self
  110.     {
  111.         $this->isPhysical $isPhysical;
  112.         return $this;
  113.     }
  114.     public function getIsCroppable(): ?bool
  115.     {
  116.         return $this->isCroppable;
  117.     }
  118.     public function setIsCroppable(bool $isCroppable): self
  119.     {
  120.         $this->isCroppable $isCroppable;
  121.         return $this;
  122.     }
  123.     public function getAllowedMimeTypes(): ?array
  124.     {
  125.         return $this->allowedMimeTypes;
  126.     }
  127.     public function setAllowedMimeTypes(?array $allowedMimeTypes): self
  128.     {
  129.         $this->allowedMimeTypes $allowedMimeTypes;
  130.         return $this;
  131.     }
  132.     public function getFile(): ?File
  133.     {
  134.         return $this->file;
  135.     }
  136.     public function setFile(?File $file): self
  137.     {
  138.         $this->file $file;
  139.         return $this;
  140.     }
  141.     public function getSeason(): ?Season
  142.     {
  143.         return $this->season;
  144.     }
  145.     public function setSeason(?Season $season): self
  146.     {
  147.         $this->season $season;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @return Collection<int, self>
  152.      */
  153.     public function getParents(): Collection
  154.     {
  155.         return $this->parents;
  156.     }
  157.     public function addParent(self $parent): self
  158.     {
  159.         if (!$this->parents->contains($parent)) {
  160.             $this->parents[] = $parent;
  161.         }
  162.         return $this;
  163.     }
  164.     public function removeParent(self $parent): self
  165.     {
  166.         $this->parents->removeElement($parent);
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return Collection<int, self>
  171.      */
  172.     public function getChildren(): Collection
  173.     {
  174.         return $this->children;
  175.     }
  176.     public function addChild(self $child): self
  177.     {
  178.         if (!$this->children->contains($child)) {
  179.             $this->children[] = $child;
  180.             $child->addParent($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeChild(self $child): self
  185.     {
  186.         if ($this->children->removeElement($child)) {
  187.             $child->removeParent($this);
  188.         }
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return Collection<int, Document>
  193.      */
  194.     public function getDocuments(): Collection
  195.     {
  196.         return $this->documents;
  197.     }
  198.     public function addDocument(Document $document): self
  199.     {
  200.         if (!$this->documents->contains($document)) {
  201.             $this->documents[] = $document;
  202.             $document->setModel($this);
  203.         }
  204.         return $this;
  205.     }
  206.     public function removeDocument(Document $document): self
  207.     {
  208.         if ($this->documents->removeElement($document)) {
  209.             // set the owning side to null (unless already changed)
  210.             if ($document->getModel() === $this) {
  211.                 $document->setModel(null);
  212.             }
  213.         }
  214.         return $this;
  215.     }
  216.     public function getDiscountModel(): ?DiscountModel
  217.     {
  218.         return $this->discountModel;
  219.     }
  220.     public function setDiscountModel(?DiscountModel $discountModel): self
  221.     {
  222.         $this->discountModel $discountModel;
  223.         return $this;
  224.     }
  225.     public function getDescription(): ?string
  226.     {
  227.         return $this->description;
  228.     }
  229.     public function setDescription(?string $description): self
  230.     {
  231.         $this->description $description;
  232.         return $this;
  233.     }
  234.     /**
  235.      * @return Collection<int, Document>
  236.      */
  237.     public function getLinkedDocuments(): Collection
  238.     {
  239.         return $this->linkedDocuments;
  240.     }
  241.     public function addLinkedDocument(Document $document): self
  242.     {
  243.         if (!$this->linkedDocuments->contains($document)) {
  244.             $this->linkedDocuments[] = $document;
  245.         }
  246.         return $this;
  247.     }
  248.     public function removeLinkedDocument(Document $document): self
  249.     {
  250.         $this->linkedDocuments->removeElement($document);
  251.         return $this;
  252.     }
  253.     public function emptyLinkedDocuments(): self
  254.     {
  255.         $this->linkedDocuments = new ArrayCollection();
  256.         return $this;
  257.     }
  258.     public function getSlug(): ?string
  259.     {
  260.         return $this->slug;
  261.     }
  262.     public function setSlug(?string $slug): self
  263.     {
  264.         $this->slug $slug;
  265.         return $this;
  266.     }
  267.     public function isAdminOnly(): ?bool
  268.     {
  269.         return $this->adminOnly;
  270.     }
  271.     public function setAdminOnly(?bool $adminOnly): self
  272.     {
  273.         $this->adminOnly $adminOnly;
  274.         return $this;
  275.     }
  276. }