<?phpnamespace App\Entity;use App\Entity\Enum\ProspectDuplicateEnum;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;/** * @ORM\Entity(repositoryClass="App\Repository\ProspectDuplicateRepository") * @ORM\EntityListeners({"App\Listener\ProspectDuplicateListener"}) */class ProspectDuplicate{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="datetime", options={"default"="CURRENT_TIMESTAMP"}) * @Gedmo\Timestampable(on="create") */ private $createdAt; /** * @ORM\ManyToOne(targetEntity="App\Entity\Prospect", inversedBy="prospectDuplicates") * @ORM\JoinColumn(nullable=false) */ private $prospect; /** * @ORM\Column(type="integer") */ private $state; /** * @ORM\Column(type="text", nullable=true) */ private $comment; /** * @ORM\Column(type="string", length=255, nullable=true) */ private $commentAdmin; /** * @ORM\ManyToMany(targetEntity=Store::class) */ private $stores; /** * @ORM\Column(type="boolean") */ private $managedByAdmin=false; /** * List of prospectOnStore created from this duplicate * @ORM\OneToMany(targetEntity=ProspectOnStore::class, mappedBy="prospectDuplicateOrigin") */ private $prospectOnStoresCreated; public function __construct() { $this->stores = new ArrayCollection(); $this->prospectOnStoresCreated = new ArrayCollection(); } public function getLabel(){ return 'Duplicate of '.$this->getProspect(); } public function getId(): ?int { return $this->id; } public function getProspect(): ?Prospect { return $this->prospect; } public function setProspect(?Prospect $prospect): self { $this->prospect = $prospect; return $this; } public function getState(): ?string { return $this->state; } public function getStateLabel(): ?string { return ProspectDuplicateEnum::getStateName( $this->state); } public function setState(string $state): self { $this->state = $state; return $this; } public function getComment(): ?string { return $this->comment; } public function setComment(?string $comment): self { $this->comment = $comment; return $this; } /** * @return mixed */ public function getCreatedAt() { return $this->createdAt; } /** * @param mixed $createdAt */ public function setCreatedAt($createdAt): void { $this->createdAt = $createdAt; } /** * @return Collection|Store[] */ public function getStores(): Collection { return $this->stores; } /** * @return Collection|Store[] */ public function getExportStores(): string { $exportStores = []; foreach ($this->getStores() as $key => $store) { $str = $store->getName() . ' (' . $store->getZipCode(). ')'; $exportStores[] = $str; } return join(' , ', $exportStores); } public function addStore(Store $store): self { if (!$this->stores->contains($store)) { $this->stores[] = $store; } return $this; } public function removeStore(Store $store): self { if ($this->stores->contains($store)) { $this->stores->removeElement($store); } return $this; } /** * Mask multi-store allowing to get a unique store to the entity (or null if none) * @return Store */ public function getStore(): ?Store { if ($this->stores->count()>0) { return $this->stores->get(0); }else{ return null; } } /** * Mask multi-store allowing to set a unique store to the entity * @param Store $store * @return ProspectDuplicate */ public function setStore(Store $store): self { $this->stores = [$store]; return $this; } public function getManagedByAdmin(): ?bool { return $this->managedByAdmin; } public function setManagedByAdmin(bool $managedByAdmin): self { $this->managedByAdmin = $managedByAdmin; return $this; } public function markAsManagedByAdmin(): self { $this->managedByAdmin = true; return $this; } public function getCommentAdmin(): ?string { return $this->commentAdmin; } public function setCommentAdmin(?string $commentAdmin): self { $this->commentAdmin = $commentAdmin; return $this; } /** * @return Collection|ProspectOnStore[] */ public function getProspectOnStoresCreated(): Collection { return $this->prospectOnStoresCreated; } public function addProspectOnStoresCreated(ProspectOnStore $prospectOnStoresCreated): self { if (!$this->prospectOnStoresCreated->contains($prospectOnStoresCreated)) { $this->prospectOnStoresCreated[] = $prospectOnStoresCreated; $prospectOnStoresCreated->setProspectDuplicateOrigin($this); } return $this; } public function removeProspectOnStoresCreated(ProspectOnStore $prospectOnStoresCreated): self { if ($this->prospectOnStoresCreated->contains($prospectOnStoresCreated)) { $this->prospectOnStoresCreated->removeElement($prospectOnStoresCreated); // set the owning side to null (unless already changed) if ($prospectOnStoresCreated->getProspectDuplicateOrigin() === $this) { $prospectOnStoresCreated->setProspectDuplicateOrigin(null); } } return $this; }}