vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Entity/Account.php line 24

  1. <?php
  2. /*
  3.  * This file is part of Sulu.
  4.  *
  5.  * (c) Sulu GmbH
  6.  *
  7.  * This source file is subject to the MIT license that is bundled
  8.  * with this source code in the file LICENSE.
  9.  */
  10. namespace Sulu\Bundle\ContactBundle\Entity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use JMS\Serializer\Annotation\Accessor;
  14. use JMS\Serializer\Annotation\Exclude;
  15. use JMS\Serializer\Annotation\Type;
  16. use Sulu\Bundle\CategoryBundle\Entity\CategoryInterface;
  17. use Sulu\Bundle\MediaBundle\Entity\MediaInterface;
  18. use Sulu\Bundle\TagBundle\Tag\TagInterface;
  19. use Sulu\Component\Security\Authentication\UserInterface;
  20. class Account implements AccountInterface
  21. {
  22.     /**
  23.      * @var int
  24.      */
  25.     private $id;
  26.     /**
  27.      * @var string
  28.      */
  29.     private $name;
  30.     /**
  31.      * @var int
  32.      */
  33.     protected $lft;
  34.     /**
  35.      * @var int
  36.      */
  37.     protected $rgt;
  38.     /**
  39.      * @var int
  40.      */
  41.     protected $depth;
  42.     /**
  43.      * @var \DateTime
  44.      */
  45.     private $created;
  46.     /**
  47.      * @var \DateTime
  48.      */
  49.     private $changed;
  50.     /**
  51.      * @var UserInterface|null
  52.      *
  53.      * @Exclude
  54.      */
  55.     private $changer;
  56.     /**
  57.      * @var UserInterface|null
  58.      *
  59.      * @Exclude
  60.      */
  61.     private $creator;
  62.     /**
  63.      * @var string|null
  64.      */
  65.     private $externalId;
  66.     /**
  67.      * @var string|null
  68.      */
  69.     private $number;
  70.     /**
  71.      * @var string|null
  72.      */
  73.     private $corporation;
  74.     /**
  75.      * @var string|null
  76.      */
  77.     private $uid;
  78.     /**
  79.      * @var string|null
  80.      */
  81.     private $registerNumber;
  82.     /**
  83.      * @var string|null
  84.      */
  85.     private $placeOfJurisdiction;
  86.     /**
  87.      * @var string|null
  88.      */
  89.     private $mainEmail;
  90.     /**
  91.      * @var string|null
  92.      */
  93.     private $mainPhone;
  94.     /**
  95.      * @var string|null
  96.      */
  97.     private $mainFax;
  98.     /**
  99.      * @var string|null
  100.      */
  101.     private $mainUrl;
  102.     /**
  103.      * @var ContactInterface|null
  104.      */
  105.     private $mainContact;
  106.     /**
  107.      * @var MediaInterface|null
  108.      */
  109.     protected $logo;
  110.     /**
  111.      * @var Collection<int, AccountInterface>
  112.      *
  113.      * @Exclude
  114.      */
  115.     protected $children;
  116.     /**
  117.      * @var AccountInterface|null
  118.      */
  119.     protected $parent;
  120.     /**
  121.      * @var string
  122.      *
  123.      * @Accessor(getter="getAddresses")
  124.      */
  125.     protected $addresses;
  126.     /**
  127.      * @var Collection<int, Url>
  128.      */
  129.     protected $urls;
  130.     /**
  131.      * @var Collection<int, Phone>
  132.      */
  133.     protected $phones;
  134.     /**
  135.      * @var Collection<int, SocialMediaProfile>
  136.      */
  137.     protected $socialMediaProfiles;
  138.     /**
  139.      * @var Collection<int, Email>
  140.      */
  141.     protected $emails;
  142.     /**
  143.      * @var Collection<int, Note>
  144.      *
  145.      * @deprecated
  146.      */
  147.     protected $notes;
  148.     /**
  149.      * @var string|null
  150.      */
  151.     protected $note;
  152.     /**
  153.      * @var Collection<int, Fax>
  154.      */
  155.     protected $faxes;
  156.     /**
  157.      * @var Collection<int, BankAccount>
  158.      */
  159.     protected $bankAccounts;
  160.     /**
  161.      * @var Collection<int, TagInterface>
  162.      *
  163.      * @Accessor(getter="getTagNameArray")
  164.      * @Type("array")
  165.      */
  166.     protected $tags;
  167.     /**
  168.      * @var Collection<int, AccountContact>
  169.      */
  170.     protected $accountContacts;
  171.     /**
  172.      * @var Collection<int, AccountAddress>
  173.      *
  174.      * @Exclude
  175.      */
  176.     protected $accountAddresses;
  177.     /**
  178.      * @var Collection<int, MediaInterface>
  179.      */
  180.     protected $medias;
  181.     /**
  182.      * @var Collection<int, CategoryInterface>
  183.      */
  184.     protected $categories;
  185.     /**
  186.      * Constructor.
  187.      */
  188.     public function __construct()
  189.     {
  190.         $this->children = new ArrayCollection();
  191.         $this->urls = new ArrayCollection();
  192.         $this->addresses = new ArrayCollection();
  193.         $this->phones = new ArrayCollection();
  194.         $this->emails = new ArrayCollection();
  195.         $this->notes = new ArrayCollection();
  196.         $this->faxes = new ArrayCollection();
  197.         $this->socialMediaProfiles = new ArrayCollection();
  198.         $this->tags = new ArrayCollection();
  199.         $this->categories = new ArrayCollection();
  200.         $this->accountContacts = new ArrayCollection();
  201.         $this->accountAddresses = new ArrayCollection();
  202.         $this->bankAccounts = new ArrayCollection();
  203.         $this->medias = new ArrayCollection();
  204.         $this->tags = new ArrayCollection();
  205.     }
  206.     public function setLft(int $lft): AccountInterface
  207.     {
  208.         $this->lft $lft;
  209.         return $this;
  210.     }
  211.     public function getLft(): int
  212.     {
  213.         return $this->lft;
  214.     }
  215.     public function setRgt(int $rgt): AccountInterface
  216.     {
  217.         $this->rgt $rgt;
  218.         return $this;
  219.     }
  220.     public function getRgt(): int
  221.     {
  222.         return $this->rgt;
  223.     }
  224.     public function setDepth(int $depth): AccountInterface
  225.     {
  226.         $this->depth $depth;
  227.         return $this;
  228.     }
  229.     public function getDepth(): int
  230.     {
  231.         return $this->depth;
  232.     }
  233.     public function setParent(?AccountInterface $parent null): AccountInterface
  234.     {
  235.         $this->parent $parent;
  236.         return $this;
  237.     }
  238.     public function getParent(): ?AccountInterface
  239.     {
  240.         return $this->parent;
  241.     }
  242.     public function addUrl(Url $url): AccountInterface
  243.     {
  244.         $this->urls[] = $url;
  245.         return $this;
  246.     }
  247.     public function removeUrl(Url $url): AccountInterface
  248.     {
  249.         $this->urls->removeElement($url);
  250.         return $this;
  251.     }
  252.     public function getUrls(): Collection
  253.     {
  254.         return $this->urls;
  255.     }
  256.     public function addPhone(Phone $phone): AccountInterface
  257.     {
  258.         $this->phones[] = $phone;
  259.         return $this;
  260.     }
  261.     public function removePhone(Phone $phone): AccountInterface
  262.     {
  263.         $this->phones->removeElement($phone);
  264.         return $this;
  265.     }
  266.     public function getPhones(): Collection
  267.     {
  268.         return $this->phones;
  269.     }
  270.     public function addEmail(Email $email): AccountInterface
  271.     {
  272.         $this->emails[] = $email;
  273.         return $this;
  274.     }
  275.     public function removeEmail(Email $email): AccountInterface
  276.     {
  277.         $this->emails->removeElement($email);
  278.         return $this;
  279.     }
  280.     public function getEmails(): Collection
  281.     {
  282.         return $this->emails;
  283.     }
  284.     public function setNote(?string $note): AccountInterface
  285.     {
  286.         $this->note $note;
  287.         return $this;
  288.     }
  289.     public function getNote(): ?string
  290.     {
  291.         return $this->note;
  292.     }
  293.     public function addNote(Note $note): AccountInterface
  294.     {
  295.         $this->notes[] = $note;
  296.         return $this;
  297.     }
  298.     public function removeNote(Note $note): AccountInterface
  299.     {
  300.         $this->notes->removeElement($note);
  301.         return $this;
  302.     }
  303.     /**
  304.      * @return Collection<int, Note>
  305.      */
  306.     public function getNotes(): Collection
  307.     {
  308.         return $this->notes;
  309.     }
  310.     public function addChildren(AccountInterface $children): AccountInterface
  311.     {
  312.         $this->children[] = $children;
  313.         return $this;
  314.     }
  315.     public function removeChildren(AccountInterface $children): AccountInterface
  316.     {
  317.         $this->children->removeElement($children);
  318.         return $this;
  319.     }
  320.     public function getChildren(): Collection
  321.     {
  322.         return $this->children;
  323.     }
  324.     public function addFax(Fax $fax): AccountInterface
  325.     {
  326.         $this->faxes[] = $fax;
  327.         return $this;
  328.     }
  329.     public function removeFax(Fax $fax): AccountInterface
  330.     {
  331.         $this->faxes->removeElement($fax);
  332.         return $this;
  333.     }
  334.     public function getFaxes(): Collection
  335.     {
  336.         return $this->faxes;
  337.     }
  338.     public function addSocialMediaProfile(SocialMediaProfile $socialMediaProfile): AccountInterface
  339.     {
  340.         $this->socialMediaProfiles[] = $socialMediaProfile;
  341.         return $this;
  342.     }
  343.     public function removeSocialMediaProfile(SocialMediaProfile $socialMediaProfile): AccountInterface
  344.     {
  345.         $this->socialMediaProfiles->removeElement($socialMediaProfile);
  346.         return $this;
  347.     }
  348.     public function getSocialMediaProfiles(): Collection
  349.     {
  350.         return $this->socialMediaProfiles;
  351.     }
  352.     public function addBankAccount(BankAccount $bankAccount): AccountInterface
  353.     {
  354.         $this->bankAccounts[] = $bankAccount;
  355.         return $this;
  356.     }
  357.     public function removeBankAccount(BankAccount $bankAccount): AccountInterface
  358.     {
  359.         $this->bankAccounts->removeElement($bankAccount);
  360.         return $this;
  361.     }
  362.     public function getBankAccounts(): Collection
  363.     {
  364.         return $this->bankAccounts;
  365.     }
  366.     public function addTag(TagInterface $tag): AccountInterface
  367.     {
  368.         $this->tags[] = $tag;
  369.         return $this;
  370.     }
  371.     public function removeTag(TagInterface $tag): AccountInterface
  372.     {
  373.         $this->tags->removeElement($tag);
  374.         return $this;
  375.     }
  376.     public function getTags(): Collection
  377.     {
  378.         return $this->tags;
  379.     }
  380.     /**
  381.      * @return string[]
  382.      */
  383.     public function getTagNameArray(): array
  384.     {
  385.         $tags = [];
  386.         foreach ($this->getTags() as $tag) {
  387.             $tags[] = $tag->getName();
  388.         }
  389.         return $tags;
  390.     }
  391.     public function addAccountContact(AccountContact $accountContact): AccountInterface
  392.     {
  393.         $this->accountContacts[] = $accountContact;
  394.         return $this;
  395.     }
  396.     public function removeAccountContact(AccountContact $accountContact): AccountInterface
  397.     {
  398.         $this->accountContacts->removeElement($accountContact);
  399.         return $this;
  400.     }
  401.     public function getAccountContacts(): Collection
  402.     {
  403.         return $this->accountContacts;
  404.     }
  405.     public function addAccountAddress(AccountAddress $accountAddress): AccountInterface
  406.     {
  407.         $this->accountAddresses[] = $accountAddress;
  408.         return $this;
  409.     }
  410.     public function removeAccountAddress(AccountAddress $accountAddress): AccountInterface
  411.     {
  412.         $this->accountAddresses->removeElement($accountAddress);
  413.         return $this;
  414.     }
  415.     public function getAccountAddresses(): Collection
  416.     {
  417.         return $this->accountAddresses;
  418.     }
  419.     /**
  420.      * @return Address[]
  421.      */
  422.     public function getAddresses(): array
  423.     {
  424.         $accountAddresses $this->getAccountAddresses();
  425.         $addresses = [];
  426.         /* @var ContactAddress $contactAddress */
  427.         foreach ($accountAddresses as $accountAddress) {
  428.             $address $accountAddress->getAddress();
  429.             $address->setPrimaryAddress($accountAddress->getMain());
  430.             $addresses[] = $address;
  431.         }
  432.         return $addresses;
  433.     }
  434.     public function getMainAddress(): ?Address
  435.     {
  436.         $accountAddresses $this->getAccountAddresses();
  437.         /** @var AccountAddress $accountAddress */
  438.         foreach ($accountAddresses as $accountAddress) {
  439.             if ($accountAddress->getMain()) {
  440.                 return $accountAddress->getAddress();
  441.             }
  442.         }
  443.         return null;
  444.     }
  445.     /**
  446.      * @return ContactInterface[]
  447.      */
  448.     public function getContacts(): array
  449.     {
  450.         $accountContacts $this->getAccountContacts();
  451.         $contacts = [];
  452.         /** @var AccountContact $accountContact */
  453.         foreach ($accountContacts as $accountContact) {
  454.             $contacts[] = $accountContact->getContact();
  455.         }
  456.         return $contacts;
  457.     }
  458.     public function addMedia(MediaInterface $media): AccountInterface
  459.     {
  460.         $this->medias[] = $media;
  461.         return $this;
  462.     }
  463.     public function removeMedia(MediaInterface $media): AccountInterface
  464.     {
  465.         $this->medias->removeElement($media);
  466.         return $this;
  467.     }
  468.     public function getMedias(): Collection
  469.     {
  470.         return $this->medias;
  471.     }
  472.     public function addChild(AccountInterface $children): AccountInterface
  473.     {
  474.         $this->children[] = $children;
  475.         return $this;
  476.     }
  477.     public function removeChild(AccountInterface $children): AccountInterface
  478.     {
  479.         $this->children->removeElement($children);
  480.         return $this;
  481.     }
  482.     public function addCategory(CategoryInterface $category): AccountInterface
  483.     {
  484.         $this->categories[] = $category;
  485.         return $this;
  486.     }
  487.     public function removeCategory(CategoryInterface $category): AccountInterface
  488.     {
  489.         $this->categories->removeElement($category);
  490.         return $this;
  491.     }
  492.     public function getCategories(): Collection
  493.     {
  494.         return $this->categories;
  495.     }
  496.     /**
  497.      * @param int $id
  498.      */
  499.     public function setId($id): AccountInterface
  500.     {
  501.         $this->id $id;
  502.         return $this;
  503.     }
  504.     public function getId(): int
  505.     {
  506.         return $this->id;
  507.     }
  508.     public function setName(string $name): AccountInterface
  509.     {
  510.         $this->name $name;
  511.         return $this;
  512.     }
  513.     public function getName(): string
  514.     {
  515.         return $this->name;
  516.     }
  517.     public function setExternalId(?string $externalId): AccountInterface
  518.     {
  519.         $this->externalId $externalId;
  520.         return $this;
  521.     }
  522.     public function getExternalId(): ?string
  523.     {
  524.         return $this->externalId;
  525.     }
  526.     public function setNumber(?string $number): AccountInterface
  527.     {
  528.         $this->number $number;
  529.         return $this;
  530.     }
  531.     public function getNumber(): ?string
  532.     {
  533.         return $this->number;
  534.     }
  535.     public function setCorporation(?string $corporation): AccountInterface
  536.     {
  537.         $this->corporation $corporation;
  538.         return $this;
  539.     }
  540.     public function getCorporation(): ?string
  541.     {
  542.         return $this->corporation;
  543.     }
  544.     public function setUid(?string $uid): AccountInterface
  545.     {
  546.         $this->uid $uid;
  547.         return $this;
  548.     }
  549.     public function getUid(): ?string
  550.     {
  551.         return $this->uid;
  552.     }
  553.     public function setRegisterNumber(?string $registerNumber): AccountInterface
  554.     {
  555.         $this->registerNumber $registerNumber;
  556.         return $this;
  557.     }
  558.     public function getRegisterNumber(): ?string
  559.     {
  560.         return $this->registerNumber;
  561.     }
  562.     public function setPlaceOfJurisdiction(?string $placeOfJurisdiction): AccountInterface
  563.     {
  564.         $this->placeOfJurisdiction $placeOfJurisdiction;
  565.         return $this;
  566.     }
  567.     public function getPlaceOfJurisdiction(): ?string
  568.     {
  569.         return $this->placeOfJurisdiction;
  570.     }
  571.     public function setMainEmail(?string $mainEmail null): AccountInterface
  572.     {
  573.         $this->mainEmail $mainEmail;
  574.         return $this;
  575.     }
  576.     public function getMainEmail(): ?string
  577.     {
  578.         return $this->mainEmail;
  579.     }
  580.     public function setMainPhone(?string $mainPhone null): AccountInterface
  581.     {
  582.         $this->mainPhone $mainPhone;
  583.         return $this;
  584.     }
  585.     public function getMainPhone(): ?string
  586.     {
  587.         return $this->mainPhone;
  588.     }
  589.     public function setMainFax(?string $mainFax null): AccountInterface
  590.     {
  591.         $this->mainFax $mainFax;
  592.         return $this;
  593.     }
  594.     public function setLogo(MediaInterface $logo): AccountInterface
  595.     {
  596.         $this->logo $logo;
  597.         return $this;
  598.     }
  599.     public function getLogo(): ?MediaInterface
  600.     {
  601.         return $this->logo;
  602.     }
  603.     public function getMainFax(): ?string
  604.     {
  605.         return $this->mainFax;
  606.     }
  607.     public function setMainUrl(?string $mainUrl null): AccountInterface
  608.     {
  609.         $this->mainUrl $mainUrl;
  610.         return $this;
  611.     }
  612.     public function getMainUrl(): ?string
  613.     {
  614.         return $this->mainUrl;
  615.     }
  616.     public function getCreated(): \DateTime
  617.     {
  618.         return $this->created;
  619.     }
  620.     public function setCreated(\DateTime $created): AccountInterface
  621.     {
  622.         $this->created $created;
  623.         return $this;
  624.     }
  625.     public function getChanged(): \DateTime
  626.     {
  627.         return $this->changed;
  628.     }
  629.     public function setChanged(\DateTime $changed): AccountInterface
  630.     {
  631.         $this->changed $changed;
  632.         return $this;
  633.     }
  634.     public function getChanger(): ?UserInterface
  635.     {
  636.         return $this->changer;
  637.     }
  638.     public function setChanger(?UserInterface $changer): AccountInterface
  639.     {
  640.         $this->changer $changer;
  641.         return $this;
  642.     }
  643.     public function getCreator(): ?UserInterface
  644.     {
  645.         return $this->creator;
  646.     }
  647.     /**
  648.      * @param UserInterface|null $creator
  649.      */
  650.     public function setCreator($creator): AccountInterface
  651.     {
  652.         $this->creator $creator;
  653.         return $this;
  654.     }
  655.     public function getMainContact(): ?ContactInterface
  656.     {
  657.         return $this->mainContact;
  658.     }
  659.     public function setMainContact(?ContactInterface $mainContact null): AccountInterface
  660.     {
  661.         $this->mainContact $mainContact;
  662.         return $this;
  663.     }
  664. }