src/Entity/Program.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProgramRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. #[ORM\Entity(repositoryClassProgramRepository::class)]
  10. #[Vich\Uploadable]
  11. class Program
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $image null;
  21.     #[Vich\UploadableField(mapping'programs_images'fileNameProperty'image')]
  22.     private ?File $imageFile null;
  23.     #[ORM\Column(length255nullabletrue)]
  24.     private ?string $season null;
  25.     #[ORM\Column(nullabletrue)]
  26.     private ?\DateTimeImmutable $updatedAt null;
  27.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'programs')]
  28.     private Collection $collaborators;
  29.     #[ORM\ManyToOne]
  30.     #[ORM\JoinColumn(nullablefalse)]
  31.     private ?User $adminUser null;
  32.     #[ORM\ManyToOne(inversedBy'programs')]
  33.     private ?Client $client null;
  34.     #[ORM\OneToMany(mappedBy'program'targetEntityProgramCandidate::class, cascade: ['remove'])]
  35.     private Collection $programCandidates;
  36.     #[ORM\Column]
  37.     private ?\DateTimeImmutable $createdAt null;
  38.     #[ORM\ManyToOne(inversedBy'programCompany')]
  39.     private ?Company $company null;
  40.     #[ORM\ManyToOne(inversedBy'programGroupe')]
  41.     private ?Groupe $groupe null;
  42.     #[ORM\Column(length255)]
  43.     private ?string $type null;
  44.     #[ORM\OneToOne(mappedBy'program'cascade: ['persist''remove'])]
  45.     private ?TrombinoscopeURL $trombinoscopeURL null;
  46.     /**
  47.      * @return \DateTimeImmutable|null
  48.      */
  49.     public function getCreatedAt(): ?\DateTimeImmutable
  50.     {
  51.         return $this->createdAt;
  52.     }
  53.     /**
  54.      * @param \DateTimeImmutable|null $createdAt
  55.      */
  56.     public function setCreatedAt(?\DateTimeImmutable $createdAt): void
  57.     {
  58.         $this->createdAt $createdAt;
  59.     }
  60.     public function __construct()
  61.     {
  62.         $this->collaborators = new ArrayCollection();
  63.         $this->programCandidates = new ArrayCollection();
  64.         $this->createdAt =  new \DateTimeImmutable();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getName(): ?string
  71.     {
  72.         return $this->name;
  73.     }
  74.     public function setName(string $name): self
  75.     {
  76.         $this->name $name;
  77.         return $this;
  78.     }
  79.     /**
  80.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  81.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  82.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  83.      * must be able to accept an instance of 'CandidateFile' as the bundle will inject one here
  84.      * during Doctrine hydration.
  85.      *
  86.      * @param CandidateFile|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  87.      */
  88.     public function setImageFile(?File $imageFile null): void
  89.     {
  90.         $this->imageFile $imageFile;
  91.         if (null !== $imageFile) {
  92.             // It is required that at least one field changes if you are using doctrine
  93.             // otherwise the event listeners won't be called and the file is lost
  94.             $this->updatedAt = new \DateTimeImmutable();
  95.         }
  96.     }
  97.     public function getImageFile(): ?File
  98.     {
  99.         return $this->imageFile;
  100.     }
  101.     public function getImage(): ?string
  102.     {
  103.         return $this->image;
  104.     }
  105.     public function setImage(?string $image): self
  106.     {
  107.         $this->image $image;
  108.         return $this;
  109.     }
  110.     public function getSeason(): ?string
  111.     {
  112.         return $this->season;
  113.     }
  114.     public function setSeason(?string $season): self
  115.     {
  116.         $this->season $season;
  117.         return $this;
  118.     }
  119.     public function getUpdatedAt(): ?\DateTimeImmutable
  120.     {
  121.         return $this->updatedAt;
  122.     }
  123.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): void
  124.     {
  125.         $this->updatedAt $updatedAt;
  126.     }
  127.     public function totalCandidate()
  128.     {
  129.        $total count($this->programCandidates);
  130.         return $total;
  131.     }
  132.     public function __toString()
  133.     {
  134.         return $this->name;
  135.     }
  136.     /**
  137.      * @return Collection<int, User>
  138.      */
  139.     public function getCollaborators(): Collection
  140.     {
  141.         return $this->collaborators;
  142.     }
  143.     public function addCollaborator(User $collaborator): self
  144.     {
  145.         if (!$this->collaborators->contains($collaborator)) {
  146.             $this->collaborators->add($collaborator);
  147.         }
  148.         return $this;
  149.     }
  150.     public function removeCollaborator(User $collaborator): self
  151.     {
  152.         $this->collaborators->removeElement($collaborator);
  153.         return $this;
  154.     }
  155.     public function getAdminUser(): ?User
  156.     {
  157.         return $this->adminUser;
  158.     }
  159.     public function setAdminUser(?User $adminUser): self
  160.     {
  161.         $this->adminUser $adminUser;
  162.         return $this;
  163.     }
  164.     public function getClient(): ?Client
  165.     {
  166.         return $this->client;
  167.     }
  168.     public function setClient(?Client $client): self
  169.     {
  170.         $this->client $client;
  171.         return $this;
  172.     }
  173.     /**
  174.      * @return Collection<int, ProgramCandidate>
  175.      */
  176.     public function getProgramCandidates(): Collection
  177.     {
  178.         return $this->programCandidates;
  179.     }
  180.     public function addProgramCandidate(ProgramCandidate $programCandidate): self
  181.     {
  182.         if (!$this->programCandidates->contains($programCandidate)) {
  183.             $this->programCandidates->add($programCandidate);
  184.             $programCandidate->setProgram($this);
  185.         }
  186.         return $this;
  187.     }
  188.     public function removeProgramCandidate(ProgramCandidate $programCandidate): self
  189.     {
  190.         if ($this->programCandidates->removeElement($programCandidate)) {
  191.             // set the owning side to null (unless already changed)
  192.             if ($programCandidate->getProgram() === $this) {
  193.                 $programCandidate->setProgram(null);
  194.             }
  195.         }
  196.         return $this;
  197.     }
  198.     public function getCompany(): ?Company
  199.     {
  200.         return $this->company;
  201.     }
  202.     public function setCompany(?Company $company): self
  203.     {
  204.         $this->company $company;
  205.         return $this;
  206.     }
  207.     public function getGroupe(): ?Groupe
  208.     {
  209.         return $this->groupe;
  210.     }
  211.     public function setGroupe(?Groupe $groupe): self
  212.     {
  213.         $this->groupe $groupe;
  214.         return $this;
  215.     }
  216.     public function getType(): ?string
  217.     {
  218.         return $this->type;
  219.     }
  220.     public function setType(string $type): self
  221.     {
  222.         $this->type $type;
  223.         return $this;
  224.     }
  225.     public function getTrombinoscopeURL(): ?TrombinoscopeURL
  226.     {
  227.         return $this->trombinoscopeURL;
  228.     }
  229.     public function setTrombinoscopeURL(?TrombinoscopeURL $trombinoscopeURL): self
  230.     {
  231.         // unset the owning side of the relation if necessary
  232.         if ($trombinoscopeURL === null && $this->trombinoscopeURL !== null) {
  233.             $this->trombinoscopeURL->setProgram(null);
  234.         }
  235.         // set the owning side of the relation if necessary
  236.         if ($trombinoscopeURL !== null && $trombinoscopeURL->getProgram() !== $this) {
  237.             $trombinoscopeURL->setProgram($this);
  238.         }
  239.         $this->trombinoscopeURL $trombinoscopeURL;
  240.         return $this;
  241.     }
  242. }