src/Entity/FrontZone.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FrontZoneRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. #[ORM\Entity(repositoryClassFrontZoneRepository::class)]
  11. class FrontZone
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     #[Groups('frontZone')]
  17.     private ?int $id null;
  18.     #[ORM\Column(length32nullabletrue)]
  19.     private ?string $htmlFileName null;
  20.     #[Gedmo\Translatable]
  21.     #[ORM\Column(length255nullabletrue)]
  22.     private ?string $title null;
  23.     #[ORM\Column(length16nullabletrue)]
  24.     private ?string $backgroundColor null;
  25.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  26.     private ?FileData $backgroundImage null;
  27.     #[ORM\Column]
  28.     #[Groups('frontZone')]
  29.     private ?bool $active null;
  30.     #[ORM\Column(typeTypes::SMALLINTnullabletrue)]
  31.     private ?int $nbElementsToDisplay null;
  32.     #[ORM\Column(length100nullabletrue)]
  33.     private ?string $query null;
  34.     #[ORM\OneToMany(mappedBy'frontZone'targetEntityFrontZoneParamValue::class, cascade: ['Persist' ,'Remove'], orphanRemovaltrue)]
  35.     #[ORM\OrderBy(['parameter' =>'ASC'])]
  36.     private Collection $frontZoneParamValues;
  37.     public function __construct()
  38.     {
  39.         $this->frontZoneParamValues = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getHtmlFileName(): ?string
  46.     {
  47.         return $this->htmlFileName;
  48.     }
  49.     public function setHtmlFileName(?string $htmlFileName): static
  50.     {
  51.         $this->htmlFileName $htmlFileName;
  52.         return $this;
  53.     }
  54.     public function getTitle(): ?string
  55.     {
  56.         return $this->title;
  57.     }
  58.     public function setTitle(?string $title): static
  59.     {
  60.         $this->title $title;
  61.         return $this;
  62.     }
  63.     public function getBackgroundColor(): ?string
  64.     {
  65.         return $this->backgroundColor;
  66.     }
  67.     public function setBackgroundColor(?string $backgroundColor): static
  68.     {
  69.         $this->backgroundColor $backgroundColor;
  70.         return $this;
  71.     }
  72.     public function isActive(): ?bool
  73.     {
  74.         return $this->active;
  75.     }
  76.     public function setActive(bool $active): static
  77.     {
  78.         $this->active $active;
  79.         return $this;
  80.     }
  81.     public function getNbElementsToDisplay(): ?int
  82.     {
  83.         return $this->nbElementsToDisplay;
  84.     }
  85.     public function setNbElementsToDisplay(?int $nbElementsToDisplay): static
  86.     {
  87.         $this->nbElementsToDisplay $nbElementsToDisplay;
  88.         return $this;
  89.     }
  90.     public function getBackgroundImage(): ?FileData
  91.     {
  92.         return $this->backgroundImage;
  93.     }
  94.     public function setBackgroundImage(?FileData $backgroundImage): self
  95.     {
  96.         $this->backgroundImage $backgroundImage;
  97.         return $this;
  98.     }
  99.     public function getQuery(): ?string
  100.     {
  101.         return $this->query;
  102.     }
  103.     public function setQuery(?string $query): static
  104.     {
  105.         $this->query $query;
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return Collection<int, FrontZoneParamValue>
  110.      */
  111.     public function getFrontZoneParamValues(): Collection
  112.     {
  113.         return $this->frontZoneParamValues;
  114.     }
  115.     public function getParametersValues(): array
  116.     {
  117.         $parameters = [];
  118.         foreach ($this->getFrontZoneParamValues() as $frontZoneParamValue){
  119.             $parameters[$frontZoneParamValue->getParameter()][] = $frontZoneParamValue->getValue();
  120.         }
  121.         return $parameters;
  122.     }
  123.     public function addFrontZoneParamValue(FrontZoneParamValue $frontZoneParamValue): static
  124.     {
  125.         if (!$this->frontZoneParamValues->contains($frontZoneParamValue)) {
  126.             $this->frontZoneParamValues->add($frontZoneParamValue);
  127.             $frontZoneParamValue->setFrontZone($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeFrontZoneParamValue(FrontZoneParamValue $frontZoneParamValue): static
  132.     {
  133.         if ($this->frontZoneParamValues->removeElement($frontZoneParamValue)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($frontZoneParamValue->getFrontZone() === $this) {
  136.                 $frontZoneParamValue->setFrontZone(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141.     public function __toString(): string
  142.     {
  143.         return 'Zone ' .$this->id;
  144.     }
  145.     public function removeAllParamValues(): void
  146.     {
  147.         foreach ($this->frontZoneParamValues as $paramValue){
  148.             $this->removeFrontZoneParamValue($paramValue);
  149.         }
  150.     }
  151.     public function addParameterValues(string $parameterNamemixed $values): void
  152.     {
  153.         foreach ($values as $value){
  154.             $parameterValue = new FrontZoneParamValue();
  155.             $parameterValue->setValue($value);
  156.             $parameterValue->setParameter($parameterName);
  157.             $this->addFrontZoneParamValue($parameterValue);
  158.         }
  159.     }
  160. }