<?php
namespace App\Entity\Main;
use App\Repository\FormuleRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Vich\UploaderBundle\Entity\File as EmbeddedFile;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @ORM\Entity(repositoryClass=FormuleRepository::class)
* @Vich\Uploadable
*/
class Formule
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $designation;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $code;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $url_formule;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $temps_limite_resa;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $nbre_mini;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $nbre_maxi;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $presence_avant;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $is_creneau_activity;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $heure_ouverture_creneau;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $heure_fermeture_creneau;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $temps_creneau;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $priority;
/**
* @ORM\Column(type="boolean")
*/
private $actif = false;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @Vich\UploadableField(mapping="product_images", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @ORM\Column(type="datetime")
*/
private $updated_at;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Main\Forfait", mappedBy="formule")
*/
private $forfaits;
public function __construct()
{
$this->forfaits = new ArrayCollection();
$this->updated_at = new \DateTime('now');
}
public function __toString()
{
return (string) $this->designation;
}
public function getId(): ?int
{
return $this->id;
}
public function getDesignation(): ?string
{
return $this->designation;
}
public function setDesignation(?string $designation): self
{
$this->designation = $designation;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function getUrlFormule(): ?string
{
return $this->url_formule;
}
public function setUrlFormule(?string $url_formule): self
{
$this->url_formule = $url_formule;
return $this;
}
public function getTempsLimiteResa(): ?int
{
return $this->temps_limite_resa;
}
public function setTempsLimiteResa(?int $temps_limite_resa): self
{
$this->temps_limite_resa = $temps_limite_resa;
return $this;
}
public function getNbreMini(): ?int
{
return $this->nbre_mini;
}
public function setNbreMini(?int $nbre_mini): self
{
$this->nbre_mini = $nbre_mini;
return $this;
}
public function getNbreMaxi(): ?int
{
return $this->nbre_maxi;
}
public function setNbreMaxi(?int $nbre_maxi): self
{
$this->nbre_maxi = $nbre_maxi;
return $this;
}
public function getPresenceAvant(): ?int
{
return $this->presence_avant;
}
public function setPresenceAvant(?int $presence_avant): self
{
$this->presence_avant = $presence_avant;
return $this;
}
public function getIsCreneauActivity(): ?bool
{
return $this->is_creneau_activity;
}
public function setIsCreneauActivity(?bool $is_creneau_activity): self
{
$this->is_creneau_activity = $is_creneau_activity;
return $this;
}
public function getHeureOuvertureCreneau(): ?\DateTimeInterface
{
return $this->heure_ouverture_creneau;
}
public function setHeureOuvertureCreneau(?\DateTimeInterface $heure_ouverture_creneau): self
{
$this->heure_ouverture_creneau = $heure_ouverture_creneau;
return $this;
}
public function getHeureFermetureCreneau(): ?\DateTimeInterface
{
return $this->heure_fermeture_creneau;
}
public function setHeureFermetureCreneau(?\DateTimeInterface $heure_fermeture_creneau): self
{
$this->heure_fermeture_creneau = $heure_fermeture_creneau;
return $this;
}
public function getTempsCreneau(): ?int
{
return $this->temps_creneau;
}
public function setTempsCreneau(?int $temps_creneau): self
{
$this->temps_creneau = $temps_creneau;
return $this;
}
public function getPriority(): ?int
{
return $this->priority;
}
public function setPriority(?int $priority): self
{
$this->priority = $priority;
return $this;
}
public function getActif(): ?bool
{
return $this->actif;
}
public function setActif(bool $actif): self
{
$this->actif = $actif;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
if ($image) {
$this->updatedAt = new \DateTime('now');
}
}
public function getImageFile()
{
return $this->imageFile;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @return Collection|Forfait[]
*/
public function getForfaits(): Collection
{
// Collect an array iterator.
$iterator = $this->forfaits->getIterator();
// Do sort the new iterator.
$iterator->uasort(function ($a, $b) {
return ($a->getPriority() < $b->getPriority()) ? -1 : 1;
});
// pass sorted array to a new ArrayCollection.
$this->forfaits = new \Doctrine\Common\Collections\ArrayCollection(iterator_to_array($iterator));
return $this->forfaits;
}
public function addForfait(Forfait $forfait): self
{
if (!$this->forfaits->contains($forfait)) {
$this->forfaits[] = $forfait;
$forfait->setFormules($this);
}
return $this;
}
public function removeForfait(Forfait $forfait): self
{
if ($this->forfaits->contains($forfait)) {
$this->forfaits->removeElement($forfait);
// set the owning side to null (unless already changed)
if ($forfait->getFormules() === $this) {
$forfait->setFormules(null);
}
}
return $this;
}
}