vendor/croisiland/common-bundle/src/Entity/Company/Company.php line 34

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Company;
  4. use Crea\MediaBundle\Entity\MediaTagOwnerInterface;
  5. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  6. use Croisiland\CommonBundle\Annotation\Company\CompanyFormValidator;
  7. use Croisiland\CommonBundle\Entity\Cabin\CabinSubType;
  8. use Croisiland\CommonBundle\Entity\Correspondence\DestinationCorrespondence;
  9. use Croisiland\CommonBundle\Entity\Itinerary\Itinerary;
  10. use Croisiland\CommonBundle\Entity\Offer\Offer;
  11. use Croisiland\CommonBundle\Entity\Partner\PartnerCompanyDiscount;
  12. use Croisiland\CommonBundle\Entity\Price\PriceCostType;
  13. use Croisiland\CommonBundle\Entity\Price\ServiceChargeType;
  14. use Croisiland\CommonBundle\Entity\Price\PriceSupplementType;
  15. use Croisiland\CommonBundle\Entity\Ship\Ship;
  16. use Croisiland\CommonBundle\Entity\Traits\IncludedExcludedTrait;
  17. use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
  18. use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
  19. use Croisiland\CommonBundle\Repository\Company\CompanyRepository;
  20. use Doctrine\Common\Collections\ArrayCollection;
  21. use Doctrine\Common\Collections\Collection;
  22. use Doctrine\Common\Util\ClassUtils;
  23. use Doctrine\ORM\Mapping as ORM;
  24. use Gedmo\Mapping\Annotation as Gedmo;
  25. /**
  26. * @ORM\Entity(repositoryClass=CompanyRepository::class)
  27. *
  28. * @CompanyFormValidator(groups={"company_form_validator"})
  29. */
  30. class Company implements MediaTagOwnerInterface
  31. {
  32. use ListOrderTrait;
  33. use IsActiveTrait;
  34. use LifecycleUserIdentifierTrait;
  35. use IncludedExcludedTrait;
  36. /**
  37. * @ORM\Id
  38. *
  39. * @ORM\GeneratedValue
  40. *
  41. * @ORM\Column(type="integer")
  42. */
  43. private ?int $id = null;
  44. /**
  45. * @ORM\Column(type="string", length=255)
  46. */
  47. private ?string $name = null;
  48. /**
  49. * @ORM\Column(type="text", name="`lead`", nullable=true)
  50. *
  51. * Note: The column name "lead" is a reserved keyword in MySQL/Percona (used by the LEAD() window function).
  52. * We use backticks in the name to avoid SQL syntax errors during schema generation and migrations.
  53. */
  54. private ?string $lead = null;
  55. /**
  56. * @ORM\Column(type="text", nullable=true)
  57. */
  58. private ?string $description = null;
  59. /**
  60. * @ORM\Column(type="text", nullable=true)
  61. */
  62. private ?string $listDescription = null;
  63. /**
  64. * @ORM\Column(type="text", nullable=true)
  65. */
  66. private ?string $midDescription = null;
  67. /**
  68. * @ORM\Column(type="text", nullable=true)
  69. */
  70. private ?string $usefulInformations = null;
  71. /**
  72. * @ORM\Column(type="text", nullable=true)
  73. */
  74. private ?string $additionalInformations = null;
  75. /**
  76. * @ORM\Column(type="string", length=64, nullable=true, unique=true)
  77. */
  78. private ?string $code = null;
  79. /**
  80. * @var Collection<int, Advantage>
  81. *
  82. * @ORM\OneToMany(targetEntity=Advantage::class, mappedBy="company", orphanRemoval=false)
  83. *
  84. * @ORM\OrderBy(value={"listOrder"="ASC"})
  85. */
  86. private Collection $advantages;
  87. /**
  88. * @var Collection<int, Atmosphere>
  89. *
  90. * @ORM\OneToMany(targetEntity=Atmosphere::class, mappedBy="company", orphanRemoval=false)
  91. * @ORM\OrderBy({"listOrder" = "ASC"})
  92. */
  93. private Collection $atmospheres;
  94. /**
  95. * @var Collection<int, Booklet>
  96. *
  97. * @ORM\OneToMany(targetEntity=Booklet::class, mappedBy="company", orphanRemoval=false)
  98. */
  99. private Collection $booklets;
  100. /**
  101. * @var Collection<int, CompanyTermsOfSelling>
  102. *
  103. * @ORM\OneToMany(targetEntity=CompanyTermsOfSelling::class, mappedBy="company", orphanRemoval=false)
  104. */
  105. private Collection $companyTermsOfSellings;
  106. /**
  107. * @var Collection<int, Ship>
  108. *
  109. * @ORM\OneToMany(targetEntity=Ship::class, mappedBy="company", orphanRemoval=false)
  110. * @ORM\OrderBy({"listOrder" = "ASC"})
  111. */
  112. private Collection $ships;
  113. /**
  114. * @var Collection<int, Itinerary>
  115. *
  116. * @ORM\OneToMany(targetEntity=Itinerary::class, mappedBy="originCompany", orphanRemoval=false)
  117. */
  118. private Collection $originatedItineraries;
  119. /**
  120. * @var Collection<int, DestinationCorrespondence>
  121. *
  122. * @ORM\OneToMany(targetEntity=DestinationCorrespondence::class, mappedBy="originCompany", orphanRemoval=false)
  123. */
  124. private Collection $originatedCorrespondencesDestinations;
  125. /**
  126. * @Gedmo\Slug(handlers={
  127. *
  128. * @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\InversedRelativeSlugHandler", options={
  129. *
  130. * @Gedmo\SlugHandlerOption(name="relationClass", value="Croisiland\CommonBundle\Entity\Ship\Ship"),
  131. * @Gedmo\SlugHandlerOption(name="mappedBy", value="company"),
  132. * @Gedmo\SlugHandlerOption(name="inverseSlugField", value="slug")
  133. * })
  134. * }, fields={"name"}, updatable=false)
  135. *
  136. * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  137. */
  138. private ?string $slug = null;
  139. /**
  140. * @var Collection<int, PartnerCompanyDiscount>
  141. *
  142. * @ORM\OneToMany(targetEntity=PartnerCompanyDiscount::class, mappedBy="company", orphanRemoval=false)
  143. */
  144. private Collection $partnerCompanyDiscounts;
  145. /**
  146. * @var Collection<int, CabinSubType>
  147. *
  148. * @ORM\OneToMany(targetEntity=CabinSubType::class, mappedBy="company", orphanRemoval=false)
  149. */
  150. private Collection $cabinSubTypes;
  151. /**
  152. * @var Collection<int, PriceCostType>
  153. *
  154. * @ORM\OneToMany(targetEntity=PriceCostType::class, mappedBy="originCompany")
  155. */
  156. private Collection $priceCostTypes;
  157. /**
  158. * @var Collection<int, ServiceChargeType>
  159. *
  160. * @ORM\OneToMany(targetEntity=ServiceChargeType::class, mappedBy="originCompany")
  161. */
  162. private Collection $serviceChargeTypes;
  163. /**
  164. * @var Collection<int, PriceSupplementType>
  165. *
  166. * @ORM\OneToMany(targetEntity=PriceSupplementType::class, mappedBy="originCompany")
  167. */
  168. private Collection $priceSupplementTypes;
  169. /**
  170. * @var Collection<int, Offer>
  171. *
  172. * @ORM\ManyToMany(targetEntity=Offer::class, mappedBy="companies")
  173. */
  174. private Collection $offers;
  175. public function __construct()
  176. {
  177. $this->advantages = new ArrayCollection();
  178. $this->atmospheres = new ArrayCollection();
  179. $this->booklets = new ArrayCollection();
  180. $this->companyTermsOfSellings = new ArrayCollection();
  181. $this->ships = new ArrayCollection();
  182. $this->partnerCompanyDiscounts = new ArrayCollection();
  183. $this->cabinSubTypes = new ArrayCollection();
  184. $this->priceCostTypes = new ArrayCollection();
  185. $this->serviceChargeTypes = new ArrayCollection();
  186. $this->priceSupplementTypes = new ArrayCollection();
  187. $this->offers = new ArrayCollection();
  188. }
  189. public function getId(): ?int
  190. {
  191. return $this->id;
  192. }
  193. public function getName(): ?string
  194. {
  195. return $this->name;
  196. }
  197. public function setName(?string $name): self
  198. {
  199. $this->name = $name;
  200. return $this;
  201. }
  202. public function getLead(): ?string
  203. {
  204. return $this->lead;
  205. }
  206. public function setLead(?string $lead): self
  207. {
  208. $this->lead = $lead;
  209. return $this;
  210. }
  211. public function getDescription(): ?string
  212. {
  213. return $this->description;
  214. }
  215. public function setDescription(?string $description): self
  216. {
  217. $this->description = $description;
  218. return $this;
  219. }
  220. public function getListDescription(): ?string
  221. {
  222. return $this->listDescription;
  223. }
  224. public function setListDescription(?string $listDescription): self
  225. {
  226. $this->listDescription = $listDescription;
  227. return $this;
  228. }
  229. public function getMidDescription(): ?string
  230. {
  231. return $this->midDescription;
  232. }
  233. public function setMidDescription(?string $midDescription): self
  234. {
  235. $this->midDescription = $midDescription;
  236. return $this;
  237. }
  238. public function getUsefulInformations(): ?string
  239. {
  240. return $this->usefulInformations;
  241. }
  242. public function setUsefulInformations(?string $usefulInformations): self
  243. {
  244. $this->usefulInformations = $usefulInformations;
  245. return $this;
  246. }
  247. public function getAdditionalInformations(): ?string
  248. {
  249. return $this->additionalInformations;
  250. }
  251. public function setAdditionalInformations(?string $additionalInformations): self
  252. {
  253. $this->additionalInformations = $additionalInformations;
  254. return $this;
  255. }
  256. public function getCode(): ?string
  257. {
  258. return $this->code;
  259. }
  260. public function setCode(?string $code): self
  261. {
  262. $this->code = $code;
  263. return $this;
  264. }
  265. /**
  266. * @return Collection<int, Advantage>
  267. */
  268. public function getAdvantages(): Collection
  269. {
  270. return $this->advantages;
  271. }
  272. public function addAdvantage(Advantage $advantage): self
  273. {
  274. if (!$this->advantages->contains($advantage)) {
  275. $this->advantages[] = $advantage;
  276. $advantage->setCompany($this);
  277. }
  278. return $this;
  279. }
  280. public function removeAdvantage(Advantage $advantage): self
  281. {
  282. if ($this->advantages->removeElement($advantage)) {
  283. // set the owning side to null (unless already changed)
  284. if ($advantage->getCompany() === $this) {
  285. $advantage->setCompany(null);
  286. }
  287. }
  288. return $this;
  289. }
  290. /**
  291. * @return Collection<int, Atmosphere>
  292. */
  293. public function getAtmospheres(): Collection
  294. {
  295. return $this->atmospheres;
  296. }
  297. public function addAtmosphere(Atmosphere $atmosphere): self
  298. {
  299. if (!$this->atmospheres->contains($atmosphere)) {
  300. $this->atmospheres[] = $atmosphere;
  301. $atmosphere->setCompany($this);
  302. }
  303. return $this;
  304. }
  305. public function removeAtmosphere(Atmosphere $atmosphere): self
  306. {
  307. if ($this->atmospheres->removeElement($atmosphere)) {
  308. // set the owning side to null (unless already changed)
  309. if ($atmosphere->getCompany() === $this) {
  310. $atmosphere->setCompany(null);
  311. }
  312. }
  313. return $this;
  314. }
  315. /**
  316. * @return Collection<int, Booklet>
  317. */
  318. public function getBooklets(): Collection
  319. {
  320. return $this->booklets;
  321. }
  322. public function addBooklet(Booklet $booklet): self
  323. {
  324. if (!$this->booklets->contains($booklet)) {
  325. $this->booklets[] = $booklet;
  326. $booklet->setCompany($this);
  327. }
  328. return $this;
  329. }
  330. public function removeBooklet(Booklet $booklet): self
  331. {
  332. if ($this->booklets->removeElement($booklet)) {
  333. // set the owning side to null (unless already changed)
  334. if ($booklet->getCompany() === $this) {
  335. $booklet->setCompany(null);
  336. }
  337. }
  338. return $this;
  339. }
  340. /**
  341. * @return Collection<int, CompanyTermsOfSelling>
  342. */
  343. public function getCompanyTermsOfSellings(): Collection
  344. {
  345. return $this->companyTermsOfSellings;
  346. }
  347. public function addCompanyTermsOfSelling(CompanyTermsOfSelling $companyTermsOfSelling): self
  348. {
  349. if (!$this->companyTermsOfSellings->contains($companyTermsOfSelling)) {
  350. $this->companyTermsOfSellings[] = $companyTermsOfSelling;
  351. $companyTermsOfSelling->setCompany($this);
  352. }
  353. return $this;
  354. }
  355. public function removeCompanyTermsOfSelling(CompanyTermsOfSelling $companyTermsOfSelling): self
  356. {
  357. if ($this->companyTermsOfSellings->removeElement($companyTermsOfSelling)) {
  358. // set the owning side to null (unless already changed)
  359. if ($companyTermsOfSelling->getCompany() === $this) {
  360. $companyTermsOfSelling->setCompany(null);
  361. }
  362. }
  363. return $this;
  364. }
  365. /**
  366. * @return Collection<int, Ship>
  367. */
  368. public function getShips(): Collection
  369. {
  370. return $this->ships;
  371. }
  372. public function addShip(Ship $ship): self
  373. {
  374. if (!$this->ships->contains($ship)) {
  375. $this->ships[] = $ship;
  376. $ship->setCompany($this);
  377. }
  378. return $this;
  379. }
  380. public function removeShip(Ship $ship): self
  381. {
  382. if ($this->ships->removeElement($ship)) {
  383. // set the owning side to null (unless already changed)
  384. if ($ship->getCompany() === $this) {
  385. $ship->setCompany(null);
  386. }
  387. }
  388. return $this;
  389. }
  390. public function getSlug(): ?string
  391. {
  392. return $this->slug;
  393. }
  394. public function setSlug(?string $slug): self
  395. {
  396. $this->slug = $slug;
  397. return $this;
  398. }
  399. /**
  400. * @return Collection<int, PartnerCompanyDiscount>
  401. */
  402. public function getPartnerCompanyDiscounts(): Collection
  403. {
  404. return $this->partnerCompanyDiscounts;
  405. }
  406. public function addPartnerCompanyDiscount(PartnerCompanyDiscount $partnerCompanyDiscount): self
  407. {
  408. if (!$this->partnerCompanyDiscounts->contains($partnerCompanyDiscount)) {
  409. $this->partnerCompanyDiscounts[] = $partnerCompanyDiscount;
  410. $partnerCompanyDiscount->setCompany($this);
  411. }
  412. return $this;
  413. }
  414. public function removePartnerCompanyDiscount(PartnerCompanyDiscount $partnerCompanyDiscount): self
  415. {
  416. if ($this->partnerCompanyDiscounts->removeElement($partnerCompanyDiscount)) {
  417. // set the owning side to null (unless already changed)
  418. if ($partnerCompanyDiscount->getCompany() === $this) {
  419. $partnerCompanyDiscount->setCompany(null);
  420. }
  421. }
  422. return $this;
  423. }
  424. /**
  425. * @return Collection<int, Itinerary>
  426. */
  427. public function getOriginatedItineraries(): Collection
  428. {
  429. return $this->originatedItineraries;
  430. }
  431. public function addOriginatedItinerary(Itinerary $originatedItinerary): self
  432. {
  433. if (!$this->originatedItineraries->contains($originatedItinerary)) {
  434. $this->originatedItineraries[] = $originatedItinerary;
  435. $originatedItinerary->setOriginCompany($this);
  436. }
  437. return $this;
  438. }
  439. public function removeOriginatedItinerary(Itinerary $originatedItinerary): self
  440. {
  441. if ($this->originatedItineraries->removeElement($originatedItinerary)) {
  442. // set the owning side to null (unless already changed)
  443. if ($originatedItinerary->getOriginCompany() === $this) {
  444. $originatedItinerary->setOriginCompany(null);
  445. }
  446. }
  447. return $this;
  448. }
  449. /**
  450. * @return Collection<int, DestinationCorrespondence>
  451. */
  452. public function getOriginatedCorrespondencesDestinations(): Collection
  453. {
  454. return $this->originatedCorrespondencesDestinations;
  455. }
  456. public function addOriginatedCorrespondencesDestinations(DestinationCorrespondence $destinationCorrespondence): self
  457. {
  458. if (!$this->originatedCorrespondencesDestinations->contains($destinationCorrespondence)) {
  459. $this->originatedCorrespondencesDestinations[] = $destinationCorrespondence;
  460. $destinationCorrespondence->setOriginCompany($this);
  461. }
  462. return $this;
  463. }
  464. public function removeOriginatedCorrespondencesDestinations(DestinationCorrespondence $destinationCorrespondence): self
  465. {
  466. if ($this->originatedCorrespondencesDestinations->removeElement($destinationCorrespondence)) {
  467. // set the owning side to null (unless already changed)
  468. if ($destinationCorrespondence->getOriginCompany() === $this) {
  469. $destinationCorrespondence->setOriginCompany(null);
  470. }
  471. }
  472. return $this;
  473. }
  474. /**
  475. * @return Collection<int, CabinSubType>
  476. */
  477. public function getCabinSubTypes(): Collection
  478. {
  479. return $this->cabinSubTypes;
  480. }
  481. public function addCabinSubType(CabinSubType $cabinSubType): self
  482. {
  483. if (!$this->cabinSubTypes->contains($cabinSubType)) {
  484. $this->cabinSubTypes[] = $cabinSubType;
  485. $cabinSubType->setCompany($this);
  486. }
  487. return $this;
  488. }
  489. public function removeCabinSubType(CabinSubType $cabinSubType): self
  490. {
  491. if ($this->cabinSubTypes->removeElement($cabinSubType)) {
  492. // set the owning side to null (unless already changed)
  493. if ($cabinSubType->getCompany() === $this) {
  494. $cabinSubType->setCompany(null);
  495. }
  496. }
  497. return $this;
  498. }
  499. /**
  500. * @return Collection<int, PriceCostType>
  501. */
  502. public function getPriceCostTypes(): Collection
  503. {
  504. return $this->priceCostTypes;
  505. }
  506. public function addPriceCostType(PriceCostType $priceCostType): self
  507. {
  508. if (!$this->priceCostTypes->contains($priceCostType)) {
  509. $this->priceCostTypes[] = $priceCostType;
  510. $priceCostType->setOriginCompany($this);
  511. }
  512. return $this;
  513. }
  514. public function removePriceCostType(PriceCostType $priceCostType): self
  515. {
  516. if ($this->priceCostTypes->removeElement($priceCostType)) {
  517. // set the owning side to null (unless already changed)
  518. if ($priceCostType->getOriginCompany() === $this) {
  519. $priceCostType->setOriginCompany(null);
  520. }
  521. }
  522. return $this;
  523. }
  524. /**
  525. * @return Collection<int, ServiceChargeType>
  526. */
  527. public function getServiceChargeTypes(): Collection
  528. {
  529. return $this->serviceChargeTypes;
  530. }
  531. public function addServiceChargeType(ServiceChargeType $serviceChargeType): self
  532. {
  533. if (!$this->serviceChargeTypes->contains($serviceChargeType)) {
  534. $this->serviceChargeTypes[] = $serviceChargeType;
  535. $serviceChargeType->setOriginCompany($this);
  536. }
  537. return $this;
  538. }
  539. public function removeServiceChargeType(ServiceChargeType $serviceChargeType): self
  540. {
  541. if ($this->serviceChargeTypes->removeElement($serviceChargeType)) {
  542. // set the owning side to null (unless already changed)
  543. if ($serviceChargeType->getOriginCompany() === $this) {
  544. $serviceChargeType->setOriginCompany(null);
  545. }
  546. }
  547. return $this;
  548. }
  549. /**
  550. * @return Collection<int, PriceSupplementType>
  551. */
  552. public function getPriceSupplementTypes(): Collection
  553. {
  554. return $this->priceSupplementTypes;
  555. }
  556. public function addPriceSupplementType(PriceSupplementType $priceSupplementType): self
  557. {
  558. if (!$this->priceSupplementTypes->contains($priceSupplementType)) {
  559. $this->priceSupplementTypes[] = $priceSupplementType;
  560. $priceSupplementType->setOriginCompany($this);
  561. }
  562. return $this;
  563. }
  564. public function removePriceSupplementType(PriceSupplementType $priceSupplementType): self
  565. {
  566. if ($this->priceSupplementTypes->removeElement($priceSupplementType)) {
  567. // set the owning side to null (unless already changed)
  568. if ($priceSupplementType->getOriginCompany() === $this) {
  569. $priceSupplementType->setOriginCompany(null);
  570. }
  571. }
  572. return $this;
  573. }
  574. /**
  575. * @return Collection<int, Offer>
  576. */
  577. public function getOffers(): Collection
  578. {
  579. return $this->offers;
  580. }
  581. public function addOffer(Offer $offer): self
  582. {
  583. if (!$this->offers->contains($offer)) {
  584. $this->offers[] = $offer;
  585. $offer->addCompany($this);
  586. }
  587. return $this;
  588. }
  589. public function removeOffer(Offer $offer): self
  590. {
  591. if ($this->offers->removeElement($offer)) {
  592. $offer->removeCompany($this);
  593. }
  594. return $this;
  595. }
  596. /**
  597. * Method liée au Média Bundle
  598. */
  599. public function getMediaTagOwnerLabel(): ?string
  600. {
  601. return $this->getName();
  602. }
  603. /**
  604. * Method liée au Média Bundle
  605. * @return class-string
  606. */
  607. public function getFqcn(): string
  608. {
  609. return ClassUtils::getClass($this);
  610. }
  611. }