vendor/croisiland/common-bundle/src/Entity/Ship/Ship.php line 28

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Ship;
  4. use Crea\MediaBundle\Entity\MediaTagOwnerInterface;
  5. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  6. use Croisiland\CommonBundle\Annotation\Ship\ShipFormValidator;
  7. use Croisiland\CommonBundle\Entity\Cabin\CabinCategory;
  8. use Croisiland\CommonBundle\Entity\Company\Booklet;
  9. use Croisiland\CommonBundle\Entity\Company\Company;
  10. use Croisiland\CommonBundle\Entity\Cruise\Cruise;
  11. use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
  12. use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
  13. use Croisiland\CommonBundle\Repository\Ship\ShipRepository;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\Common\Util\ClassUtils;
  17. use Doctrine\ORM\Mapping as ORM;
  18. use Gedmo\Mapping\Annotation as Gedmo;
  19. /**
  20. * @ORM\Entity(repositoryClass=ShipRepository::class)
  21. *
  22. * @ShipFormValidator(groups={"ship_form_validator"})
  23. */
  24. class Ship implements MediaTagOwnerInterface
  25. {
  26. // TODO: relations
  27. // private $images;
  28. use IsActiveTrait;
  29. use LifecycleUserIdentifierTrait;
  30. use ListOrderTrait;
  31. /**
  32. * @ORM\Id
  33. *
  34. * @ORM\GeneratedValue
  35. *
  36. * @ORM\Column(type="integer")
  37. */
  38. private ?int $id;
  39. /**
  40. * @ORM\Column(type="string", length=255)
  41. */
  42. private ?string $name = null;
  43. /**
  44. * @ORM\Column(type="string", length=64, nullable=true)
  45. */
  46. private ?string $code = null;
  47. /**
  48. * @Gedmo\Slug(handlers={
  49. *
  50. * @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\RelativeSlugHandler", options={
  51. *
  52. * @Gedmo\SlugHandlerOption(name="relationField", value="company"),
  53. * @Gedmo\SlugHandlerOption(name="relationSlugField", value="slug"),
  54. * @Gedmo\SlugHandlerOption(name="separator", value="-"),
  55. * })
  56. * }, fields={"name"})
  57. *
  58. * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  59. */
  60. private ?string $slug = null;
  61. /**
  62. * @ORM\Column(type="text", nullable=true)
  63. */
  64. private ?string $description = null;
  65. /**
  66. * @ORM\Column(type="text", nullable=true)
  67. */
  68. private ?string $shortDescription = null;
  69. /**
  70. * @ORM\Column(type="text", nullable=true)
  71. */
  72. private ?string $longDescription = null;
  73. /**
  74. * @ORM\Column(type="smallint", nullable=true)
  75. */
  76. private ?int $numberOfMembers = null;
  77. /**
  78. * @ORM\Column(type="smallint", nullable=true)
  79. */
  80. private ?int $numberOfDecks = null;
  81. /**
  82. * @ORM\Column(type="smallint", nullable=true)
  83. */
  84. private ?int $numberOfCabins = null;
  85. /**
  86. * @ORM\Column(type="smallint", nullable=true)
  87. */
  88. private ?int $numberOfPassengers = null;
  89. /**
  90. * @ORM\Column(type="smallint", nullable=true)
  91. */
  92. private ?int $speed = null;
  93. /**
  94. * @ORM\Column(type="smallint", nullable=true)
  95. */
  96. private ?int $width = null;
  97. /**
  98. * @ORM\Column(type="smallint", nullable=true)
  99. */
  100. private ?int $length = null;
  101. /**
  102. * @ORM\Column(type="integer", nullable=true)
  103. */
  104. private ?int $tonnage = null;
  105. /**
  106. * @ORM\Column(type="smallint", nullable=true)
  107. */
  108. private ?int $renovationYear = null;
  109. /**
  110. * @ORM\Column(type="smallint", nullable=true)
  111. */
  112. private ?int $constructionYear = null;
  113. /**
  114. * @ORM\Column(type="text", nullable=true)
  115. */
  116. private ?string $additionalInformations = null;
  117. /**
  118. * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="ships")
  119. *
  120. * @ORM\JoinColumn(nullable=false)
  121. */
  122. private ?Company $company = null;
  123. /**
  124. * @ORM\ManyToOne(targetEntity=Fuel::class, inversedBy="ships")
  125. */
  126. private ?Fuel $fuel = null;
  127. /**
  128. * @var Collection<int, CabinCategory>
  129. *
  130. * @ORM\OneToMany(targetEntity=CabinCategory::class, mappedBy="ship", orphanRemoval=true)
  131. * @ORM\OrderBy({"listOrder" = "ASC"})
  132. */
  133. private Collection $cabinCategories;
  134. /**
  135. * @var Collection<int, Cruise>
  136. *
  137. * @ORM\OneToMany(targetEntity=Cruise::class, mappedBy="ship")
  138. * @ORM\OrderBy({"departureDate" = "ASC"})
  139. */
  140. private Collection $cruises;
  141. /**
  142. * @var Collection<int, Booklet>
  143. *
  144. * @ORM\ManyToMany(targetEntity=Booklet::class, mappedBy="ships")
  145. * @ORM\OrderBy({"listOrder" = "ASC"})
  146. */
  147. private $booklets;
  148. /**
  149. * @var Collection<int, OnBoardLife>
  150. *
  151. * @ORM\ManyToMany(targetEntity=OnBoardLife::class, mappedBy="ships")
  152. */
  153. private Collection $onBoardLives;
  154. /**
  155. * @var Collection<int, ShipEnvironmentalAction>
  156. *
  157. * @ORM\ManyToMany(targetEntity=ShipEnvironmentalAction::class, mappedBy="ships")
  158. */
  159. private Collection $shipEnvironmentalActions;
  160. public function __construct()
  161. {
  162. $this->cabinCategories = new ArrayCollection();
  163. $this->cruises = new ArrayCollection();
  164. $this->booklets = new ArrayCollection();
  165. $this->onBoardLives = new ArrayCollection();
  166. $this->shipEnvironmentalActions = new ArrayCollection();
  167. }
  168. public function getId(): ?int
  169. {
  170. return $this->id;
  171. }
  172. public function getName(): ?string
  173. {
  174. return $this->name;
  175. }
  176. public function setName(?string $name): self
  177. {
  178. $this->name = $name;
  179. return $this;
  180. }
  181. public function getCode(): ?string
  182. {
  183. return $this->code;
  184. }
  185. public function setCode(?string $code): self
  186. {
  187. $this->code = $code;
  188. return $this;
  189. }
  190. public function getCompany(): ?Company
  191. {
  192. return $this->company;
  193. }
  194. public function setCompany(?Company $company): self
  195. {
  196. $this->company = $company;
  197. return $this;
  198. }
  199. public function getFuel(): ?Fuel
  200. {
  201. return $this->fuel;
  202. }
  203. public function setFuel(?Fuel $fuel): self
  204. {
  205. $this->fuel = $fuel;
  206. return $this;
  207. }
  208. /**
  209. * @return Collection<int, CabinCategory>
  210. */
  211. public function getCabinCategories(): Collection
  212. {
  213. return $this->cabinCategories;
  214. }
  215. public function addCabinCategory(CabinCategory $cabinCategory): self
  216. {
  217. if (!$this->cabinCategories->contains($cabinCategory)) {
  218. $this->cabinCategories[] = $cabinCategory;
  219. $cabinCategory->setShip($this);
  220. }
  221. return $this;
  222. }
  223. public function removeCabinCategory(CabinCategory $cabinCategory): self
  224. {
  225. if ($this->cabinCategories->removeElement($cabinCategory)) {
  226. // set the owning side to null (unless already changed)
  227. if ($cabinCategory->getShip() === $this) {
  228. $cabinCategory->setShip(null);
  229. }
  230. }
  231. return $this;
  232. }
  233. /**
  234. * @return Collection<int, Cruise>
  235. */
  236. public function getCruises(): Collection
  237. {
  238. return $this->cruises;
  239. }
  240. public function addCruise(Cruise $cruise): self
  241. {
  242. if (!$this->cruises->contains($cruise)) {
  243. $this->cruises[] = $cruise;
  244. $cruise->setShip($this);
  245. }
  246. return $this;
  247. }
  248. public function removeCruise(Cruise $cruise): self
  249. {
  250. if ($this->cruises->removeElement($cruise)) {
  251. // set the owning side to null (unless already changed)
  252. if ($cruise->getShip() === $this) {
  253. $cruise->setShip(null);
  254. }
  255. }
  256. return $this;
  257. }
  258. public function getSlug(): ?string
  259. {
  260. return $this->slug;
  261. }
  262. public function setSlug(?string $slug): self
  263. {
  264. $this->slug = $slug;
  265. return $this;
  266. }
  267. /**
  268. * @return Collection<int, Booklet>
  269. */
  270. public function getBooklets(): Collection
  271. {
  272. return $this->booklets;
  273. }
  274. public function addBooklet(Booklet $booklet): self
  275. {
  276. if (!$this->booklets->contains($booklet)) {
  277. $this->booklets[] = $booklet;
  278. $booklet->addShip($this);
  279. }
  280. return $this;
  281. }
  282. public function removeBooklet(Booklet $booklet): self
  283. {
  284. if ($this->booklets->removeElement($booklet)) {
  285. $booklet->removeShip($this);
  286. }
  287. return $this;
  288. }
  289. /**
  290. * @return Collection<int, OnBoardLife>
  291. */
  292. public function getOnBoardLives(): Collection
  293. {
  294. return $this->onBoardLives;
  295. }
  296. public function addOnBoardLife(OnBoardLife $onBoardLife): self
  297. {
  298. if (!$this->onBoardLives->contains($onBoardLife)) {
  299. $this->onBoardLives[] = $onBoardLife;
  300. $onBoardLife->addShip($this);
  301. }
  302. return $this;
  303. }
  304. public function removeOnBoardLife(OnBoardLife $onBoardLife): self
  305. {
  306. if ($this->onBoardLives->removeElement($onBoardLife)) {
  307. $onBoardLife->removeShip($this);
  308. }
  309. return $this;
  310. }
  311. public function getDescription(): ?string
  312. {
  313. return $this->description;
  314. }
  315. public function setDescription(?string $description): self
  316. {
  317. $this->description = $description;
  318. return $this;
  319. }
  320. public function getShortDescription(): ?string
  321. {
  322. return $this->shortDescription;
  323. }
  324. public function setShortDescription(?string $shortDescription): self
  325. {
  326. $this->shortDescription = $shortDescription;
  327. return $this;
  328. }
  329. public function getLongDescription(): ?string
  330. {
  331. return $this->longDescription;
  332. }
  333. public function setLongDescription(?string $longDescription): self
  334. {
  335. $this->longDescription = $longDescription;
  336. return $this;
  337. }
  338. public function getNumberOfMembers(): ?int
  339. {
  340. return $this->numberOfMembers;
  341. }
  342. public function setNumberOfMembers(?int $numberOfMembers): self
  343. {
  344. $this->numberOfMembers = $numberOfMembers;
  345. return $this;
  346. }
  347. public function getNumberOfDecks(): ?int
  348. {
  349. return $this->numberOfDecks;
  350. }
  351. public function setNumberOfDecks(?int $numberOfDecks): self
  352. {
  353. $this->numberOfDecks = $numberOfDecks;
  354. return $this;
  355. }
  356. public function getNumberOfCabins(): ?int
  357. {
  358. return $this->numberOfCabins;
  359. }
  360. public function setNumberOfCabins(?int $numberOfCabins): self
  361. {
  362. $this->numberOfCabins = $numberOfCabins;
  363. return $this;
  364. }
  365. public function getNumberOfPassengers(): ?int
  366. {
  367. return $this->numberOfPassengers;
  368. }
  369. public function setNumberOfPassengers(?int $numberOfPassengers): self
  370. {
  371. $this->numberOfPassengers = $numberOfPassengers;
  372. return $this;
  373. }
  374. public function getSpeed(): ?int
  375. {
  376. return $this->speed;
  377. }
  378. public function setSpeed(?int $speed): self
  379. {
  380. $this->speed = $speed;
  381. return $this;
  382. }
  383. public function getWidth(): ?int
  384. {
  385. return $this->width;
  386. }
  387. public function setWidth(?int $width): self
  388. {
  389. $this->width = $width;
  390. return $this;
  391. }
  392. public function getLength(): ?int
  393. {
  394. return $this->length;
  395. }
  396. public function setLength(?int $length): self
  397. {
  398. $this->length = $length;
  399. return $this;
  400. }
  401. public function getTonnage(): ?int
  402. {
  403. return $this->tonnage;
  404. }
  405. public function setTonnage(?int $tonnage): self
  406. {
  407. $this->tonnage = $tonnage;
  408. return $this;
  409. }
  410. public function getRenovationYear(): ?int
  411. {
  412. return $this->renovationYear;
  413. }
  414. public function setRenovationYear(?int $renovationYear): self
  415. {
  416. $this->renovationYear = $renovationYear;
  417. return $this;
  418. }
  419. public function getConstructionYear(): ?int
  420. {
  421. return $this->constructionYear;
  422. }
  423. public function setConstructionYear(?int $constructionYear): self
  424. {
  425. $this->constructionYear = $constructionYear;
  426. return $this;
  427. }
  428. public function getAdditionalInformations(): ?string
  429. {
  430. return $this->additionalInformations;
  431. }
  432. public function setAdditionalInformations(?string $additionalInformations): self
  433. {
  434. $this->additionalInformations = $additionalInformations;
  435. return $this;
  436. }
  437. /**
  438. * @return Collection<int, ShipEnvironmentalAction>
  439. */
  440. public function getShipEnvironmentalActions(): Collection
  441. {
  442. return $this->shipEnvironmentalActions;
  443. }
  444. public function addShipEnvironmentalAction(ShipEnvironmentalAction $shipEnvironmentalAction): self
  445. {
  446. if (!$this->shipEnvironmentalActions->contains($shipEnvironmentalAction)) {
  447. $this->shipEnvironmentalActions[] = $shipEnvironmentalAction;
  448. $shipEnvironmentalAction->addShip($this);
  449. }
  450. return $this;
  451. }
  452. public function removeShipEnvironmentalAction(ShipEnvironmentalAction $shipEnvironmentalAction): self
  453. {
  454. if ($this->shipEnvironmentalActions->removeElement($shipEnvironmentalAction)) {
  455. $shipEnvironmentalAction->removeShip($this);
  456. }
  457. return $this;
  458. }
  459. /**
  460. * Method liée au Média Bundle
  461. */
  462. public function getMediaTagOwnerLabel(): ?string
  463. {
  464. return $this->getName();
  465. }
  466. /**
  467. * Method liée au Média Bundle
  468. * @return class-string
  469. */
  470. public function getFqcn(): string
  471. {
  472. return ClassUtils::getClass($this);
  473. }
  474. }