src/Entity/Program.php line 14
<?php
namespace App\Entity;
use App\Repository\ProgramRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: ProgramRepository::class)]
#[Vich\Uploadable]
class Program
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image = null;
#[Vich\UploadableField(mapping: 'programs_images', fileNameProperty: 'image')]
private ?File $imageFile = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $season = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'programs')]
private Collection $collaborators;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?User $adminUser = null;
#[ORM\ManyToOne(inversedBy: 'programs')]
private ?Client $client = null;
#[ORM\OneToMany(mappedBy: 'program', targetEntity: ProgramCandidate::class, cascade: ['remove'])]
private Collection $programCandidates;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\ManyToOne(inversedBy: 'programCompany')]
private ?Company $company = null;
#[ORM\ManyToOne(inversedBy: 'programGroupe')]
private ?Groupe $groupe = null;
#[ORM\Column(length: 255)]
private ?string $type = null;
#[ORM\OneToOne(mappedBy: 'program', cascade: ['persist', 'remove'])]
private ?TrombinoscopeURL $trombinoscopeURL = null;
/**
* @return \DateTimeImmutable|null
*/
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
/**
* @param \DateTimeImmutable|null $createdAt
*/
public function setCreatedAt(?\DateTimeImmutable $createdAt): void
{
$this->createdAt = $createdAt;
}
public function __construct()
{
$this->collaborators = new ArrayCollection();
$this->programCandidates = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'CandidateFile' as the bundle will inject one here
* during Doctrine hydration.
*
* @param CandidateFile|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
*/
public function setImageFile(?File $imageFile = null): void
{
$this->imageFile = $imageFile;
if (null !== $imageFile) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getSeason(): ?string
{
return $this->season;
}
public function setSeason(?string $season): self
{
$this->season = $season;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
public function totalCandidate()
{
$total = count($this->programCandidates);
return $total;
}
public function __toString()
{
return $this->name;
}
/**
* @return Collection<int, User>
*/
public function getCollaborators(): Collection
{
return $this->collaborators;
}
public function addCollaborator(User $collaborator): self
{
if (!$this->collaborators->contains($collaborator)) {
$this->collaborators->add($collaborator);
}
return $this;
}
public function removeCollaborator(User $collaborator): self
{
$this->collaborators->removeElement($collaborator);
return $this;
}
public function getAdminUser(): ?User
{
return $this->adminUser;
}
public function setAdminUser(?User $adminUser): self
{
$this->adminUser = $adminUser;
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(?Client $client): self
{
$this->client = $client;
return $this;
}
/**
* @return Collection<int, ProgramCandidate>
*/
public function getProgramCandidates(): Collection
{
return $this->programCandidates;
}
public function addProgramCandidate(ProgramCandidate $programCandidate): self
{
if (!$this->programCandidates->contains($programCandidate)) {
$this->programCandidates->add($programCandidate);
$programCandidate->setProgram($this);
}
return $this;
}
public function removeProgramCandidate(ProgramCandidate $programCandidate): self
{
if ($this->programCandidates->removeElement($programCandidate)) {
// set the owning side to null (unless already changed)
if ($programCandidate->getProgram() === $this) {
$programCandidate->setProgram(null);
}
}
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
public function getGroupe(): ?Groupe
{
return $this->groupe;
}
public function setGroupe(?Groupe $groupe): self
{
$this->groupe = $groupe;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getTrombinoscopeURL(): ?TrombinoscopeURL
{
return $this->trombinoscopeURL;
}
public function setTrombinoscopeURL(?TrombinoscopeURL $trombinoscopeURL): self
{
// unset the owning side of the relation if necessary
if ($trombinoscopeURL === null && $this->trombinoscopeURL !== null) {
$this->trombinoscopeURL->setProgram(null);
}
// set the owning side of the relation if necessary
if ($trombinoscopeURL !== null && $trombinoscopeURL->getProgram() !== $this) {
$trombinoscopeURL->setProgram($this);
}
$this->trombinoscopeURL = $trombinoscopeURL;
return $this;
}
}