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

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