<?php
namespace App\Entity;
use App\Repository\PosteRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=PosteRepository::class)
*/
class Poste extends EntityBase
{
/**
* @Groups("api")
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=PosteDirector::class, inversedBy="postes")
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank(groups="creationPoste")
*/
private $posteDirector;
/**
* @Groups("api")
* @ORM\ManyToOne(targetEntity=Employee::class)
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank(groups="creationPoste")
*/
private $responsable;
/**
* @ORM\ManyToOne(targetEntity=Localite::class, inversedBy="postes")
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank(groups="creationPoste")
*/
private $localite;
/**
* @ORM\OneToMany(targetEntity=Vacation::class, mappedBy="poste")
*/
private $vacations;
/**
* @Groups("api")
* @ORM\ManyToOne(targetEntity=ResListeDeChoix::class)
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank(groups="creationPoste")
*/
private $type;
/**
* @ORM\OneToMany(targetEntity=Device::class, mappedBy="poste")
*/
private $devices;
/**
* @Groups("api")
* @ORM\OneToMany(targetEntity=PosteConfig::class, mappedBy="poste", orphanRemoval=true,cascade={"persist"})
* @ORM\OrderBy({"ordre" = "ASC"})
*/
private $posteConfigs;
/**
* @ORM\OneToMany(targetEntity=DemandeVacation::class, mappedBy="poste")
*/
private $demandeVacations;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $telephone;
public function __construct()
{
$this->vacations = new ArrayCollection();
$this->devices = new ArrayCollection();
$this->posteConfigs = new ArrayCollection();
$this->demandeVacations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getPosteDirector(): ?PosteDirector
{
return $this->posteDirector;
}
public function setPosteDirector(?PosteDirector $posteDirector): self
{
$this->posteDirector = $posteDirector;
return $this;
}
public function getResponsable(): ?Employee
{
return $this->responsable;
}
public function setResponsable(?Employee $responsable): self
{
$this->responsable = $responsable;
return $this;
}
public function getLocalite(): ?Localite
{
return $this->localite;
}
public function setLocalite(?Localite $localite): self
{
$this->localite = $localite;
return $this;
}
/**
* @return Collection<int, Vacation>
*/
public function getVacations(): Collection
{
return $this->vacations;
}
public function addVacation(Vacation $vacation): self
{
if (!$this->vacations->contains($vacation)) {
$this->vacations[] = $vacation;
$vacation->setPoste($this);
}
return $this;
}
public function removeVacation(Vacation $vacation): self
{
if ($this->vacations->removeElement($vacation)) {
// set the owning side to null (unless already changed)
if ($vacation->getPoste() === $this) {
$vacation->setPoste(null);
}
}
return $this;
}
public function getType(): ?ResListeDeChoix
{
return $this->type;
}
public function setType(?ResListeDeChoix $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, Device>
*/
public function getDevices(): Collection
{
return $this->devices;
}
public function addDevice(Device $device): self
{
if (!$this->devices->contains($device)) {
$this->devices[] = $device;
$device->setPoste($this);
}
return $this;
}
public function removeDevice(Device $device): self
{
if ($this->devices->removeElement($device)) {
// set the owning side to null (unless already changed)
if ($device->getPoste() === $this) {
$device->setPoste(null);
}
}
return $this;
}
/**
* @return Collection<int, PosteConfig>
*/
public function getPosteConfigs(): Collection
{
return $this->posteConfigs;
}
public function addPosteConfig(PosteConfig $posteConfig): self
{
if (!$this->posteConfigs->contains($posteConfig)) {
$this->posteConfigs[] = $posteConfig;
$posteConfig->setPoste($this);
}
return $this;
}
public function removePosteConfig(PosteConfig $posteConfig): self
{
if ($this->posteConfigs->removeElement($posteConfig)) {
// set the owning side to null (unless already changed)
if ($posteConfig->getPoste() === $this) {
$posteConfig->setPoste(null);
}
}
return $this;
}
/**
* @return Collection<int, DemandeVacation>
*/
public function getDemandeVacations(): Collection
{
return $this->demandeVacations;
}
public function addDemandeVacation(DemandeVacation $demandeVacation): self
{
if (!$this->demandeVacations->contains($demandeVacation)) {
$this->demandeVacations[] = $demandeVacation;
$demandeVacation->setPoste($this);
}
return $this;
}
public function removeDemandeVacation(DemandeVacation $demandeVacation): self
{
if ($this->demandeVacations->removeElement($demandeVacation)) {
// set the owning side to null (unless already changed)
if ($demandeVacation->getPoste() === $this) {
$demandeVacation->setPoste(null);
}
}
return $this;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
}