src/Entity/ProspectDuplicate.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Enum\ProspectDuplicateEnum;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\ProspectDuplicateRepository")
  10.  * @ORM\EntityListeners({"App\Listener\ProspectDuplicateListener"})
  11.  */
  12. class ProspectDuplicate
  13. {
  14.     /**
  15.      * @ORM\Id()
  16.      * @ORM\GeneratedValue()
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="datetime", options={"default"="CURRENT_TIMESTAMP"})
  22.      * @Gedmo\Timestampable(on="create")
  23.      */
  24.     private $createdAt;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="App\Entity\Prospect", inversedBy="prospectDuplicates")
  27.      * @ORM\JoinColumn(nullable=false)
  28.      */
  29.     private $prospect;
  30.     /**
  31.      * @ORM\Column(type="integer")
  32.      */
  33.     private $state;
  34.     /**
  35.      * @ORM\Column(type="text", nullable=true)
  36.      */
  37.     private $comment;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private $commentAdmin;
  42.     /**
  43.      * @ORM\ManyToMany(targetEntity=Store::class)
  44.      */
  45.     private $stores;
  46.     /**
  47.      * @ORM\Column(type="boolean")
  48.      */
  49.     private $managedByAdmin=false;
  50.     /**
  51.      * List of prospectOnStore created from this duplicate
  52.      * @ORM\OneToMany(targetEntity=ProspectOnStore::class, mappedBy="prospectDuplicateOrigin")
  53.      */
  54.     private $prospectOnStoresCreated;
  55.     public function __construct()
  56.     {
  57.         $this->stores = new ArrayCollection();
  58.         $this->prospectOnStoresCreated = new ArrayCollection();
  59.     }
  60.     public function getLabel(){
  61.         return 'Duplicate of '.$this->getProspect();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getProspect(): ?Prospect
  68.     {
  69.         return $this->prospect;
  70.     }
  71.     public function setProspect(?Prospect $prospect): self
  72.     {
  73.         $this->prospect $prospect;
  74.         return $this;
  75.     }
  76.     public function getState(): ?string
  77.     {
  78.         return $this->state;
  79.     }
  80.     public function getStateLabel(): ?string
  81.     {
  82.         return ProspectDuplicateEnum::getStateName$this->state);
  83.     }
  84.     public function setState(string $state): self
  85.     {
  86.         $this->state $state;
  87.         return $this;
  88.     }
  89.     public function getComment(): ?string
  90.     {
  91.         return $this->comment;
  92.     }
  93.     public function setComment(?string $comment): self
  94.     {
  95.         $this->comment $comment;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return mixed
  100.      */
  101.     public function getCreatedAt()
  102.     {
  103.         return $this->createdAt;
  104.     }
  105.     /**
  106.      * @param mixed $createdAt
  107.      */
  108.     public function setCreatedAt($createdAt): void
  109.     {
  110.         $this->createdAt $createdAt;
  111.     }
  112.     /**
  113.      * @return Collection|Store[]
  114.      */
  115.     public function getStores(): Collection
  116.     {
  117.         return $this->stores;
  118.     }
  119.     /**
  120.      * @return Collection|Store[]
  121.      */
  122.     public function getExportStores(): string
  123.     {
  124.         $exportStores = [];
  125.         foreach ($this->getStores() as $key => $store) {
  126.             $str $store->getName() . ' (' $store->getZipCode(). ')';
  127.             $exportStores[] = $str;
  128.         }
  129.         return join(' , '$exportStores);
  130.     }
  131.     public function addStore(Store $store): self
  132.     {
  133.         if (!$this->stores->contains($store)) {
  134.             $this->stores[] = $store;
  135.         }
  136.         return $this;
  137.     }
  138.     public function removeStore(Store $store): self
  139.     {
  140.         if ($this->stores->contains($store)) {
  141.             $this->stores->removeElement($store);
  142.         }
  143.         return $this;
  144.     }
  145.     /**
  146.      * Mask multi-store allowing to get a unique store to the entity (or null if none)
  147.      * @return Store
  148.      */
  149.     public function getStore(): ?Store
  150.     {
  151.         if ($this->stores->count()>0) {
  152.             return $this->stores->get(0);
  153.         }else{
  154.             return null;
  155.         }
  156.     }
  157.     /**
  158.      * Mask multi-store allowing to set a unique store to the entity
  159.      * @param Store $store
  160.      * @return ProspectDuplicate
  161.      */
  162.     public function setStore(Store $store): self
  163.     {
  164.         $this->stores = [$store];
  165.         return $this;
  166.     }
  167.     public function getManagedByAdmin(): ?bool
  168.     {
  169.         return $this->managedByAdmin;
  170.     }
  171.     public function setManagedByAdmin(bool $managedByAdmin): self
  172.     {
  173.         $this->managedByAdmin $managedByAdmin;
  174.         return $this;
  175.     }
  176.     public function markAsManagedByAdmin(): self
  177.     {
  178.         $this->managedByAdmin true;
  179.         return $this;
  180.     }
  181.     public function getCommentAdmin(): ?string
  182.     {
  183.         return $this->commentAdmin;
  184.     }
  185.     public function setCommentAdmin(?string $commentAdmin): self
  186.     {
  187.         $this->commentAdmin $commentAdmin;
  188.         return $this;
  189.     }
  190.     /**
  191.      * @return Collection|ProspectOnStore[]
  192.      */
  193.     public function getProspectOnStoresCreated(): Collection
  194.     {
  195.         return $this->prospectOnStoresCreated;
  196.     }
  197.     public function addProspectOnStoresCreated(ProspectOnStore $prospectOnStoresCreated): self
  198.     {
  199.         if (!$this->prospectOnStoresCreated->contains($prospectOnStoresCreated)) {
  200.             $this->prospectOnStoresCreated[] = $prospectOnStoresCreated;
  201.             $prospectOnStoresCreated->setProspectDuplicateOrigin($this);
  202.         }
  203.         return $this;
  204.     }
  205.     public function removeProspectOnStoresCreated(ProspectOnStore $prospectOnStoresCreated): self
  206.     {
  207.         if ($this->prospectOnStoresCreated->contains($prospectOnStoresCreated)) {
  208.             $this->prospectOnStoresCreated->removeElement($prospectOnStoresCreated);
  209.             // set the owning side to null (unless already changed)
  210.             if ($prospectOnStoresCreated->getProspectDuplicateOrigin() === $this) {
  211.                 $prospectOnStoresCreated->setProspectDuplicateOrigin(null);
  212.             }
  213.         }
  214.         return $this;
  215.     }
  216. }