src/Entity/Contact.php line 20

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  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 App\Repository\ContactRepository;
  9. /**
  10.  * Contact
  11.  *
  12.  * @ORM\Table(name="contact", indexes={@ORM\Index(name="sourceID", columns={"source_id"}), @ORM\Index(name="csptypeID", columns={"csptype_id"}), @ORM\Index(name="lock_user", columns={"lock_user"}), @ORM\Index(name="countryID", columns={"country_id"}), @ORM\Index(name="cspID", columns={"csp_id"})})
  13.  * @ORM\Entity(repositoryClass=ContactRepository::class)
  14.  * @ORM\HasLifecycleCallbacks()
  15.  */
  16. class Contact
  17. {
  18.     public const TITLE_MR 'Mr';
  19.     public const TITLE_MS 'Ms';
  20.     public const TITLE_MRS 'Mrs';
  21.     public const TITLE_PR 'Pr';
  22.     public const TITLE_DR 'Dr';
  23.     public const OPERATION_CLONE 'clone';
  24.     public const OPERATION_UPDATE 'update';
  25.     public const OPERATION_RELATED 'related';
  26.     /**
  27.      * @var int
  28.      *
  29.      * @ORM\Column(name="id", type="integer", nullable=false)
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue(strategy="IDENTITY")
  32.      */
  33.     private $id;
  34.     /**
  35.      * @var string|null
  36.      *
  37.      * @ORM\Column(name="title", type="string", length=4, nullable=true, options={"default"="NULL"})
  38.      */
  39.     private $title null;
  40.     /**
  41.      * @var string|null
  42.      *
  43.      * @ORM\Column(name="fname", type="string", length=40, nullable=true, options={"default"="NULL"})
  44.      */
  45.     private $fname null;
  46.     /**
  47.      * @var string|null
  48.      *
  49.      * @ORM\Column(name="lname", type="string", length=40, nullable=true, options={"default"="NULL"})
  50.      */
  51.     private $lname null;
  52.     /**
  53.      * @var string|null
  54.      *
  55.      * @ORM\Column(name="email", type="string", length=64, nullable=true, options={"default"="NULL"})
  56.      */
  57.     private $email null;
  58.     /**
  59.      * @var bool
  60.      *
  61.      * @ORM\Column(name="valid_email", type="boolean", nullable=false, options={"default"="1"})
  62.      */
  63.     private $validEmail true;
  64.     /**
  65.      * @var string|null
  66.      *
  67.      * @ORM\Column(name="position", type="string", length=110, nullable=true, options={"default"="NULL"})
  68.      */
  69.     private $position null;
  70.     /**
  71.      * @var string|null
  72.      *
  73.      * @ORM\Column(name="division", type="string", length=80, nullable=true, options={"default"="NULL"})
  74.      */
  75.     private $division null;
  76.     /**
  77.      * @var string|null
  78.      *
  79.      * @ORM\Column(name="phone1", type="string", length=100, nullable=true, options={"default"="NULL"})
  80.      */
  81.     private $phone1 null;
  82.     /**
  83.      * @var string|null
  84.      *
  85.      * @ORM\Column(name="phone2", type="string", length=100, nullable=true, options={"default"="NULL"})
  86.      */
  87.     private $phone2 null;
  88.     /**
  89.      * @var string|null
  90.      *
  91.      * @ORM\Column(name="corp_phone", type="string", length=100, nullable=true, options={"default"="NULL"})
  92.      */
  93.     private $corpPhone null;
  94.     /**
  95.      * @var string|null
  96.      *
  97.      * @ORM\Column(name="linkedin_url", type="string", length=120, nullable=true, options={"default"="NULL"})
  98.      */
  99.     private $linkedinUrl null;
  100.     /**
  101.      * @var string|null
  102.      *
  103.      * @ORM\Column(name="city", type="string", length=64, nullable=true, options={"default"="NULL"})
  104.      */
  105.     private $city null;
  106.     /**
  107.      * @var string|null
  108.      *
  109.      * @ORM\Column(name="comment", type="text", length=65535, nullable=true, options={"default"="NULL"})
  110.      */
  111.     private $comment null;
  112.     /**
  113.      * @var \DateTime|null
  114.      *
  115.      * @ORM\Column(name="lock_date", type="datetime", nullable=true, options={"default"="NULL"})
  116.      */
  117.     private $lockDate null;
  118.     /**
  119.      * @var \DateTime|null
  120.      *
  121.      * @ORM\Column(name="updated_at", type="datetime", nullable=true, options={"default"="NULL"})
  122.      */
  123.     private $updatedAt null;
  124.     /**
  125.      * @var \DateTime|null
  126.      *
  127.      * @ORM\Column(name="missing_data", type="datetime", nullable=true, options={"default"="NULL"})
  128.      */
  129.     private $missingData null;
  130.     /**
  131.      * @var bool|null
  132.      *
  133.      * @ORM\Column(name="last_import", type="boolean", nullable=true)
  134.      */
  135.     private $lastImport false;
  136.     /**
  137.      * @var bool
  138.      *
  139.      * @ORM\Column(name="trash", type="boolean", nullable=false)
  140.      */
  141.     private $trash false;
  142.     /**
  143.      * @var bool
  144.      *
  145.      * @ORM\Column(name="last_delete", type="boolean", nullable=false)
  146.      */
  147.     private $lastDelete false;
  148.     /**
  149.      * @var \Country
  150.      *
  151.      * @ORM\ManyToOne(targetEntity="Country")
  152.      * @ORM\JoinColumns({
  153.      *   @ORM\JoinColumn(name="country_id", referencedColumnName="id")
  154.      * })
  155.      */
  156.     private $country;
  157.     /**
  158.      * @var \Source
  159.      *
  160.      * @ORM\ManyToOne(targetEntity="Source")
  161.      * @ORM\JoinColumns({
  162.      *   @ORM\JoinColumn(name="source_id", referencedColumnName="id")
  163.      * })
  164.      */
  165.     private $source;
  166.     /**
  167.      * @var \Csp
  168.      *
  169.      * @ORM\ManyToOne(targetEntity="Csp")
  170.      * @ORM\JoinColumns({
  171.      *   @ORM\JoinColumn(name="csp_id", referencedColumnName="id")
  172.      * })
  173.      */
  174.     private $csp;
  175.     /**
  176.      * @var \Csptype
  177.      *
  178.      * @ORM\ManyToOne(targetEntity="Csptype")
  179.      * @ORM\JoinColumns({
  180.      *   @ORM\JoinColumn(name="csptype_id", referencedColumnName="id")
  181.      * })
  182.      */
  183.     private $csptype;
  184.     /**
  185.      * @var \User
  186.      *
  187.      * @ORM\ManyToOne(targetEntity="User")
  188.      * @ORM\JoinColumns({
  189.      *   @ORM\JoinColumn(name="lock_user", referencedColumnName="id")
  190.      * })
  191.      */
  192.     private $lockUser;
  193.     /**
  194.      * @var \Doctrine\Common\Collections\Collection
  195.      *
  196.      * @ORM\ManyToMany(targetEntity="Conference", mappedBy="contact")
  197.      */
  198.     //private $conference;
  199.     /**
  200.      * @ORM\OneToMany(targetEntity="RelatedContact", mappedBy="parentContact", fetch="EXTRA_LAZY")
  201.      */
  202.     private $relatedContacts;
  203.     /**
  204.      * @ORM\OneToMany(targetEntity="RelatedContact", mappedBy="relatedContact", fetch="EXTRA_LAZY")
  205.      */
  206.     private $parentContacts;
  207.     /**
  208.      * @ORM\OneToMany(targetEntity="ContactCompanyType", mappedBy="contact", fetch="EXTRA_LAZY")
  209.      */
  210.     private $companyTypes;
  211.     /**
  212.      * Constructor
  213.      */
  214.     public function __construct()
  215.     {
  216.         $this->relatedContacts = new ArrayCollection();
  217.         $this->parentContacts = new ArrayCollection();
  218.         $this->companyTypes = new ArrayCollection();
  219.     }
  220.     public function getId(): ?int
  221.     {
  222.         return $this->id;
  223.     }
  224.     public function getTitle(): ?string
  225.     {
  226.         return $this->title;
  227.     }
  228.     public function setTitle(?string $title): self
  229.     {
  230.         $this->title $title;
  231.         return $this;
  232.     }
  233.     public function getFname(): ?string
  234.     {
  235.         return $this->fname;
  236.     }
  237.     public function setFname(?string $fname): self
  238.     {
  239.         $this->fname $fname;
  240.         return $this;
  241.     }
  242.     public function getLname(): ?string
  243.     {
  244.         return $this->lname;
  245.     }
  246.     public function setLname(?string $lname): self
  247.     {
  248.         $this->lname $lname;
  249.         return $this;
  250.     }
  251.     public function getEmail(): ?string
  252.     {
  253.         return $this->email;
  254.     }
  255.     public function setEmail(?string $email): self
  256.     {
  257.         $this->email $email;
  258.         return $this;
  259.     }
  260.     public function isValidEmail(): ?bool
  261.     {
  262.         return $this->validEmail;
  263.     }
  264.     public function setValidEmail(bool $validEmail): self
  265.     {
  266.         $this->validEmail $validEmail;
  267.         return $this;
  268.     }
  269.     public function getPosition(): ?string
  270.     {
  271.         return $this->position;
  272.     }
  273.     public function setPosition(?string $position): self
  274.     {
  275.         $this->position $position;
  276.         return $this;
  277.     }
  278.     public function getDivision(): ?string
  279.     {
  280.         return $this->division;
  281.     }
  282.     public function setDivision(?string $division): self
  283.     {
  284.         $this->division $division;
  285.         return $this;
  286.     }
  287.     public function getPhone1(): ?string
  288.     {
  289.         return $this->phone1;
  290.     }
  291.     public function setPhone1(?string $phone1): self
  292.     {
  293.         $this->phone1 $phone1;
  294.         return $this;
  295.     }
  296.     public function getPhone2(): ?string
  297.     {
  298.         return $this->phone2;
  299.     }
  300.     public function setPhone2(?string $phone2): self
  301.     {
  302.         $this->phone2 $phone2;
  303.         return $this;
  304.     }
  305.     public function getCorpPhone(): ?string
  306.     {
  307.         return $this->corpPhone;
  308.     }
  309.     public function setCorpPhone(?string $corpPhone): self
  310.     {
  311.         $this->corpPhone $corpPhone;
  312.         return $this;
  313.     }
  314.     public function getLinkedinUrl(): ?string
  315.     {
  316.         return $this->linkedinUrl;
  317.     }
  318.     public function setLinkedinUrl(?string $linkedinUrl): self
  319.     {
  320.         $this->linkedinUrl $linkedinUrl;
  321.         return $this;
  322.     }
  323.     public function getCity(): ?string
  324.     {
  325.         return $this->city;
  326.     }
  327.     public function setCity(?string $city): self
  328.     {
  329.         $this->city $city;
  330.         return $this;
  331.     }
  332.     public function getComment(): ?string
  333.     {
  334.         return $this->comment;
  335.     }
  336.     public function setComment(?string $comment): self
  337.     {
  338.         $this->comment $comment;
  339.         return $this;
  340.     }
  341.     public function getLockDate(): ?\DateTimeInterface
  342.     {
  343.         return $this->lockDate;
  344.     }
  345.     public function setLockDate(?\DateTimeInterface $lockDate): self
  346.     {
  347.         $this->lockDate $lockDate;
  348.         return $this;
  349.     }
  350.     public function getUpdatedAt(): ?\DateTimeInterface
  351.     {
  352.         return $this->updatedAt;
  353.     }
  354.     /**
  355.      * @ORM\PrePersist
  356.      */
  357.     public function setUpdatedAt(): self
  358.     {
  359.         $this->updatedAt = new \DateTimeImmutable();
  360.         return $this;
  361.     }
  362.     public function getMissingData(): ?\DateTimeInterface
  363.     {
  364.         return $this->missingData;
  365.     }
  366.     public function setMissingData(?\DateTimeInterface $missingData): self
  367.     {
  368.         $this->missingData $missingData;
  369.         return $this;
  370.     }
  371.     public function isLastImport(): ?bool
  372.     {
  373.         return $this->lastImport;
  374.     }
  375.     public function setLastImport(?bool $lastImport): self
  376.     {
  377.         $this->lastImport $lastImport;
  378.         return $this;
  379.     }
  380.     public function isTrash(): ?bool
  381.     {
  382.         return $this->trash;
  383.     }
  384.     public function setTrash(bool $trash): self
  385.     {
  386.         $this->trash $trash;
  387.         return $this;
  388.     }
  389.     public function isLastDelete(): ?bool
  390.     {
  391.         return $this->lastDelete;
  392.     }
  393.     public function setLastDelete(bool $lastDelete): self
  394.     {
  395.         $this->lastDelete $lastDelete;
  396.         return $this;
  397.     }
  398.     public function getCountry(): ?Country
  399.     {
  400.         return $this->country;
  401.     }
  402.     public function setCountry(?Country $country): self
  403.     {
  404.         $this->country $country;
  405.         return $this;
  406.     }
  407.     public function getSource(): ?Source
  408.     {
  409.         return $this->source;
  410.     }
  411.     public function setSource(?Source $source): self
  412.     {
  413.         $this->source $source;
  414.         return $this;
  415.     }
  416.     public function getCsp(): ?Csp
  417.     {
  418.         return $this->csp;
  419.     }
  420.     public function setCsp(?Csp $csp): self
  421.     {
  422.         $this->csp $csp;
  423.         return $this;
  424.     }
  425.     public function getCsptype(): ?Csptype
  426.     {
  427.         return $this->csptype;
  428.     }
  429.     public function setCsptype(?Csptype $csptype): self
  430.     {
  431.         $this->csptype $csptype;
  432.         return $this;
  433.     }
  434.     public function getLockUser(): ?User
  435.     {
  436.         return $this->lockUser;
  437.     }
  438.     public function setLockUser(?User $lockUser): self
  439.     {
  440.         $this->lockUser $lockUser;
  441.         return $this;
  442.     }
  443.     /**
  444.      * @return Collection<int, Conference>
  445.      */
  446.     /*public function getConference(): Collection
  447.     {
  448.         return $this->conference;
  449.     }
  450.     public function addConference(Conference $conference): self
  451.     {
  452.         if (!$this->conference->contains($conference)) {
  453.             $this->conference[] = $conference;
  454.             $conference->addContact($this);
  455.         }
  456.         return $this;
  457.     }
  458.     public function removeConference(Conference $conference): self
  459.     {
  460.         if ($this->conference->removeElement($conference)) {
  461.             $conference->removeContact($this);
  462.         }
  463.         return $this;
  464.     }*/
  465.     /**
  466.      * @return Collection<int, RelatedContact>
  467.      */
  468.     public function getRelatedContacts(): Collection
  469.     {
  470.         return $this->relatedContacts;
  471.     }
  472.     public function addRelatedContact(RelatedContact $relatedContact): self
  473.     {
  474.         if (!$this->relatedContacts->contains($relatedContact)) {
  475.             $this->relatedContacts[] = $relatedContact;
  476.             $relatedContact->setParentContact($this);
  477.         }
  478.         return $this;
  479.     }
  480.     public function removeRelatedContact(RelatedContact $relatedContact): self
  481.     {
  482.         if ($this->relatedContacts->removeElement($relatedContact)) {
  483.             // set the owning side to null (unless already changed)
  484.             if ($relatedContact->getParentContact() === $this) {
  485.                 $relatedContact->setParentContact(null);
  486.             }
  487.         }
  488.         return $this;
  489.     }
  490.     /**
  491.      * @return Collection<int, RelatedContact>
  492.      */
  493.     public function getParentContacts(): Collection
  494.     {
  495.         return $this->parentContacts;
  496.     }
  497.     public function addParentContact(RelatedContact $parentContact): self
  498.     {
  499.         if (!$this->parentContacts->contains($parentContact)) {
  500.             $this->parentContacts[] = $parentContact;
  501.             $parentContact->setRelatedContact($this);
  502.         }
  503.         return $this;
  504.     }
  505.     public function removeParentContact(RelatedContact $parentContact): self
  506.     {
  507.         if ($this->parentContacts->removeElement($parentContact)) {
  508.             // set the owning side to null (unless already changed)
  509.             if ($parentContact->getRelatedContact() === $this) {
  510.                 $parentContact->setRelatedContact(null);
  511.             }
  512.         }
  513.         return $this;
  514.     }
  515.     public function equals(Contact $contact): bool
  516.     {
  517.         if (
  518.             $this->getFname() === $contact->getFname()
  519.             && $this->getLname() === $contact->getLname()
  520.             && $this->getEmail() === $contact->getEmail()
  521.             && $this->getLinkedinUrl() === $contact->getLinkedinUrl()
  522.             && $this->getPhone1() === $contact->getPhone1()
  523.             && $this->getPhone2() === $contact->getPhone2()
  524.             && $this->isValidEmail() === $contact->isValidEmail()
  525.             && $this->getPosition() === $contact->getPosition()
  526.         ) {
  527.             return true;
  528.         }
  529.         return false;
  530.     }
  531.     /**
  532.      * @return Collection<int, ContactCompanyType>
  533.      */
  534.     public function getCompanyTypes(): Collection
  535.     {
  536.         return $this->companyTypes;
  537.     }
  538.     public function addCompanyType(ContactCompanyType $companyType): self
  539.     {
  540.         if (!$this->companyTypes->contains($companyType)) {
  541.             $this->companyTypes->add($companyType);
  542.             $companyType->setContact($this);
  543.         }
  544.         return $this;
  545.     }
  546.     public function removeCompanyType(ContactCompanyType $companyType): self
  547.     {
  548.         if ($this->companyTypes->removeElement($companyType)) {
  549.             // set the owning side to null (unless already changed)
  550.             if ($companyType->getContact() === $this) {
  551.                 $companyType->setContact(null);
  552.             }
  553.         }
  554.         return $this;
  555.     }
  556. }