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