src/Entity/FormLead.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\ActivableTrait;
  4. use App\Entity\Traits\EntityIdTrait;
  5. use App\Entity\Traits\TimestampableTrait;
  6. use App\Repository\FormLeadRepository;
  7. use DateTime;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Exception;
  12. use Symfony\Component\Uid\Uuid;
  13. /**
  14.  * @ORM\Entity(repositoryClass=FormLeadRepository::class)
  15.  * @ORM\HasLifecycleCallbacks()
  16.  */
  17. class FormLead
  18. {
  19.     use EntityIdTrait;
  20.     use TimestampableTrait;
  21.     use ActivableTrait;
  22.     /**
  23.      * @var DateTime
  24.      * @ORM\Column(type="datetime")
  25.      */
  26.     private $periodStartsAt;
  27.     /**
  28.      * @var DateTime
  29.      * @ORM\Column(type="datetime")
  30.      */
  31.     private $periodUpdatedAt;
  32.     /**
  33.      * @var bool
  34.      * @ORM\Column(type="boolean")
  35.      */
  36.     private $eventForced false;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity=Campaign::class, inversedBy="formLeads")
  39.      * @ORM\JoinColumn(nullable=false)
  40.      */
  41.     private $campaign;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=FormLeadData::class, mappedBy="formLead")
  44.      */
  45.     private $formLeadData;
  46.     /**
  47.      * @var array
  48.      * @ORM\Column(type="array", nullable=true)
  49.      */
  50.     private $annexPdfIgnoredFields;
  51.     public function __construct()
  52.     {
  53.         $this->formLeadData = new ArrayCollection();
  54.         $this->uuid Uuid::v6();
  55.     }
  56.     /**
  57.      * @return DateTime|null
  58.      */
  59.     public function getPeriodStartsAt(): ?DateTime
  60.     {
  61.         return $this->periodStartsAt;
  62.     }
  63.     /**
  64.      * @param DateTime $periodStartsAt
  65.      * @return $this
  66.      */
  67.     public function setPeriodStartsAt(DateTime $periodStartsAt): self
  68.     {
  69.         $this->periodStartsAt $periodStartsAt;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return DateTime|null
  74.      */
  75.     public function getPeriodUpdatedAt(): ?DateTime
  76.     {
  77.         return $this->periodUpdatedAt;
  78.     }
  79.     /**
  80.      * @param DateTime $periodUpdatedAt
  81.      * @return $this
  82.      */
  83.     public function setPeriodUpdatedAt(DateTime $periodUpdatedAt): self
  84.     {
  85.         $this->periodUpdatedAt $periodUpdatedAt;
  86.         return $this;
  87.     }
  88.     /**
  89.      * @return bool
  90.      */
  91.     public function isEventForced(): bool
  92.     {
  93.         return $this->eventForced;
  94.     }
  95.     /**
  96.      * @param bool $eventForced
  97.      * @return $this
  98.      */
  99.     public function setEventForced(bool $eventForced): self
  100.     {
  101.         $this->eventForced $eventForced;
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Campaign|null
  106.      */
  107.     public function getCampaign(): ?Campaign
  108.     {
  109.         return $this->campaign;
  110.     }
  111.     /**
  112.      * @param Campaign|null $campaign
  113.      * @return $this
  114.      */
  115.     public function setCampaign(?Campaign $campaign): self
  116.     {
  117.         $this->campaign $campaign;
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, FormLeadData>
  122.      */
  123.     public function getFormLeadData(): Collection
  124.     {
  125.         return $this->formLeadData;
  126.     }
  127.     /**
  128.      * @param FormLeadData $formLeadData
  129.      * @return $this
  130.      */
  131.     public function addFormLeadData(FormLeadData $formLeadData): self
  132.     {
  133.         if (!$this->formLeadData->contains($formLeadData)) {
  134.             $this->formLeadData[] = $formLeadData;
  135.             $formLeadData->setFormLead($this);
  136.         }
  137.         return $this;
  138.     }
  139.     /**
  140.      * @param FormLeadData $formLeadData
  141.      * @return $this
  142.      */
  143.     public function removeFormLeadData(FormLeadData $formLeadData): self
  144.     {
  145.         if ($this->formLeadData->removeElement($formLeadData)) {
  146.             // set the owning side to null (unless already changed)
  147.             if ($formLeadData->getFormLead() === $this) {
  148.                 $formLeadData->setFormLead(null);
  149.             }
  150.         }
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return ArrayCollection
  155.      * @throws Exception
  156.      */
  157.     public function getOrderedByCreateFormLeadData(): ArrayCollection
  158.     {
  159.         $collection = new ArrayCollection();
  160.         foreach ($this->formLeadData as $item) {
  161.             $collection->add($item);
  162.         }
  163.         $iterator $collection->getIterator();
  164.         $iterator->uasort(function (FormLeadData $aFormLeadData $b) {
  165.             return ($a->getCreatedAt() > $b->getCreatedAt()) ? -1;
  166.         });
  167.         return new ArrayCollection(iterator_to_array($iterator));
  168.     }
  169.     /**
  170.      * @return array
  171.      */
  172.     public function getAnnexPdfIgnoredFields(): ?array
  173.     {
  174.         return $this->annexPdfIgnoredFields;
  175.     }
  176.     /**
  177.      * @param array $exporteadFields
  178.      * @return $this
  179.      */
  180.     public function setAnnexPdfIgnoredFields(array $ignoredFields): self
  181.     {
  182.         $this->annexPdfIgnoredFields $ignoredFields;
  183.         return $this;
  184.     }
  185. }