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