vendor/croisiland/common-bundle/src/Entity/Flight/FlightPackage.php line 17

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Flight;
  4. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  5. use Croisiland\CommonBundle\Entity\Price\Price;
  6. use Croisiland\CommonBundle\Repository\Flight\FlightPackageRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11. * @ORM\Entity(repositoryClass=FlightPackageRepository::class)
  12. */
  13. class FlightPackage
  14. {
  15. use LifecycleUserIdentifierTrait;
  16. /**
  17. * @ORM\Id
  18. *
  19. * @ORM\GeneratedValue
  20. *
  21. * @ORM\Column(type="integer")
  22. */
  23. private ?int $id;
  24. /**
  25. * @ORM\ManyToOne(targetEntity=Flight::class)
  26. */
  27. private ?Flight $outboundFlight;
  28. /**
  29. * @ORM\ManyToOne(targetEntity=Flight::class)
  30. */
  31. private ?Flight $inboundFlight;
  32. /**
  33. * @var Collection<int, FlightCost>
  34. *
  35. * @ORM\OneToMany(targetEntity=FlightCost::class, mappedBy="flightPackage", orphanRemoval=true)
  36. */
  37. private $flightCosts;
  38. /**
  39. * @ORM\ManyToOne(targetEntity=Price::class, inversedBy="flightPackages")
  40. *
  41. * @ORM\JoinColumn(nullable=false)
  42. */
  43. private Price $price;
  44. public function __construct()
  45. {
  46. $this->flightCosts = new ArrayCollection();
  47. }
  48. public function getOutboundFlight(): ?Flight
  49. {
  50. return $this->outboundFlight;
  51. }
  52. public function setOutboundFlight(?Flight $outboundFlight): self
  53. {
  54. $this->outboundFlight = $outboundFlight;
  55. return $this;
  56. }
  57. public function getInboundFlight(): ?Flight
  58. {
  59. return $this->inboundFlight;
  60. }
  61. public function setInboundFlight(?Flight $inboundFlight): self
  62. {
  63. $this->inboundFlight = $inboundFlight;
  64. return $this;
  65. }
  66. /**
  67. * @return Collection<int, FlightCost>
  68. */
  69. public function getFlightCosts(): Collection
  70. {
  71. return $this->flightCosts;
  72. }
  73. public function addFlightCost(FlightCost $flightCost): self
  74. {
  75. if (!$this->flightCosts->contains($flightCost)) {
  76. $this->flightCosts[] = $flightCost;
  77. $flightCost->setFlightPackage($this);
  78. }
  79. return $this;
  80. }
  81. public function removeFlightCost(FlightCost $flightCost): self
  82. {
  83. if ($this->flightCosts->removeElement($flightCost)) {
  84. // set the owning side to null (unless already changed)
  85. if ($flightCost->getFlightPackage() === $this) {
  86. $flightCost->setFlightPackage(null);
  87. }
  88. }
  89. return $this;
  90. }
  91. public function getPrice(): ?Price
  92. {
  93. return $this->price;
  94. }
  95. public function setPrice(?Price $price): self
  96. {
  97. $this->price = $price;
  98. return $this;
  99. }
  100. }