vendor/croisiland/common-bundle/src/Entity/Itinerary/Activity.php line 26

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Itinerary;
  4. use Crea\ParameterBundle\Entity\Parameter;
  5. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  6. use Croisiland\CommonBundle\Entity\Company\Company;
  7. use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
  8. use Croisiland\CommonBundle\Repository\Itinerary\ActivityRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. /**
  13. * @ORM\Entity(repositoryClass=ActivityRepository::class)
  14. *
  15. * @ORM\Table(
  16. * uniqueConstraints={
  17. *
  18. * @ORM\UniqueConstraint(name="activity_unique", columns={"code", "company_id"})
  19. * }
  20. * )
  21. */
  22. class Activity
  23. {
  24. use ListOrderTrait;
  25. use LifecycleUserIdentifierTrait;
  26. /**
  27. * @ORM\Id
  28. *
  29. * @ORM\GeneratedValue
  30. *
  31. * @ORM\Column(type="integer")
  32. */
  33. private ?int $id = null;
  34. /**
  35. * @ORM\Column(type="string", length=255, nullable=false)
  36. */
  37. private ?string $code = null;
  38. /**
  39. * @ORM\Column(type="string", length=255, nullable=false)
  40. */
  41. private ?string $name = null;
  42. /**
  43. * @ORM\Column(type="text", nullable=true)
  44. */
  45. private ?string $description = null;
  46. /**
  47. * @ORM\ManyToOne(targetEntity=Parameter::class)
  48. *
  49. * @ORM\JoinColumn(nullable=false)
  50. */
  51. private ?Parameter $activityType = null;
  52. /**
  53. * @ORM\ManyToOne(targetEntity=Company::class)
  54. *
  55. * @ORM\JoinColumn(nullable=false)
  56. */
  57. private ?Company $company = null;
  58. /**
  59. * @var Collection<int, ItineraryActivity>
  60. *
  61. * @ORM\OneToMany(targetEntity=ItineraryActivity::class, mappedBy="activity", orphanRemoval=true, cascade={"remove"})
  62. */
  63. private $itineraryActivities;
  64. public function __construct()
  65. {
  66. $this->itineraryActivities = new ArrayCollection();
  67. }
  68. public function getId(): ?int
  69. {
  70. return $this->id;
  71. }
  72. public function getCode(): ?string
  73. {
  74. return $this->code;
  75. }
  76. public function setCode(string $code): self
  77. {
  78. $this->code = $code;
  79. return $this;
  80. }
  81. public function getName(): ?string
  82. {
  83. return $this->name;
  84. }
  85. public function setName(string $name): self
  86. {
  87. $this->name = $name;
  88. return $this;
  89. }
  90. public function getDescription(): ?string
  91. {
  92. return $this->description;
  93. }
  94. public function setDescription(?string $description): self
  95. {
  96. $this->description = $description;
  97. return $this;
  98. }
  99. public function getActivityType(): ?Parameter
  100. {
  101. return $this->activityType;
  102. }
  103. public function setActivityType(?Parameter $activityType): self
  104. {
  105. $this->activityType = $activityType;
  106. return $this;
  107. }
  108. public function getCompany(): ?Company
  109. {
  110. return $this->company;
  111. }
  112. public function setCompany(?Company $company): self
  113. {
  114. $this->company = $company;
  115. return $this;
  116. }
  117. /**
  118. * @return Collection<int, ItineraryActivity>
  119. */
  120. public function getItineraryActivities(): Collection
  121. {
  122. return $this->itineraryActivities;
  123. }
  124. public function addItineraryActivity(ItineraryActivity $itineraryActivity): self
  125. {
  126. if (!$this->itineraryActivities->contains($itineraryActivity)) {
  127. $this->itineraryActivities[] = $itineraryActivity;
  128. $itineraryActivity->setActivity($this);
  129. }
  130. return $this;
  131. }
  132. public function removeItineraryActivity(ItineraryActivity $itineraryActivity): self
  133. {
  134. if ($this->itineraryActivities->removeElement($itineraryActivity)) {
  135. // set the owning side to null (unless already changed)
  136. if ($itineraryActivity->getActivity() === $this) {
  137. $itineraryActivity->setActivity(null);
  138. }
  139. }
  140. return $this;
  141. }
  142. }