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

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Ship;
  4. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  5. use Croisiland\CommonBundle\Annotation\Ship\ShipEnvironmentalActionFormValidator;
  6. use Croisiland\CommonBundle\Repository\Ship\ShipEnvironmentalActionRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11. * @ORM\Entity(repositoryClass=ShipEnvironmentalActionRepository::class)
  12. *
  13. * @ShipEnvironmentalActionFormValidator(groups={"ship_environmental_action_form_validator"})
  14. */
  15. class ShipEnvironmentalAction
  16. {
  17. use LifecycleUserIdentifierTrait;
  18. /**
  19. * @ORM\Id
  20. *
  21. * @ORM\GeneratedValue
  22. *
  23. * @ORM\Column(type="integer")
  24. */
  25. private ?int $id;
  26. /**
  27. * @ORM\Column(type="string", length=255)
  28. */
  29. private ?string $name = null;
  30. /**
  31. * @var Collection<int, Ship>
  32. *
  33. * @ORM\ManyToMany(targetEntity=Ship::class, inversedBy="shipEnvironmentalActions")
  34. */
  35. private Collection $ships;
  36. public function __construct()
  37. {
  38. $this->ships = new ArrayCollection();
  39. }
  40. public function getId(): ?int
  41. {
  42. return $this->id;
  43. }
  44. public function getName(): ?string
  45. {
  46. return $this->name;
  47. }
  48. public function setName(?string $name): self
  49. {
  50. $this->name = $name;
  51. return $this;
  52. }
  53. /**
  54. * @return Collection<int, Ship>
  55. */
  56. public function getShips(): Collection
  57. {
  58. return $this->ships;
  59. }
  60. public function addShip(Ship $ship): self
  61. {
  62. if (!$this->ships->contains($ship)) {
  63. $this->ships[] = $ship;
  64. $ship->addShipEnvironmentalAction($this);
  65. }
  66. return $this;
  67. }
  68. public function removeShip(Ship $ship): self
  69. {
  70. if ($this->ships->removeElement($ship)) {
  71. $ship->removeShipEnvironmentalAction($this);
  72. }
  73. return $this;
  74. }
  75. }