188 lines
4.7 KiB
PHP
188 lines
4.7 KiB
PHP
<?php
|
|
|
|
namespace AppBundle\Entity;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
/**
|
|
* TravelArrivalPoint
|
|
*
|
|
* @ORM\Table(name="travel_arrival_point", indexes={@ORM\Index(name="FK_travel_arrival_point_travel_country", columns={"travel_country_id"})})
|
|
* @ORM\Entity
|
|
*/
|
|
class TravelArrivalPoint
|
|
{
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="name", type="string", length=255, nullable=true)
|
|
*/
|
|
private $name;
|
|
|
|
/**
|
|
* @var integer
|
|
*
|
|
* @ORM\Column(name="id", type="integer")
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue(strategy="IDENTITY")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @var \AppBundle\Entity\TravelCountry
|
|
*
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelCountry")
|
|
* @ORM\JoinColumns({
|
|
* @ORM\JoinColumn(name="travel_country_id", referencedColumnName="id")
|
|
* })
|
|
*/
|
|
private $travelCountry;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelDeparturePoint", mappedBy="travelArrivalPoint")
|
|
*/
|
|
private $departures;
|
|
|
|
/**
|
|
* Set name
|
|
*
|
|
* @param string $name
|
|
*
|
|
* @return TravelArrivalPoint
|
|
*/
|
|
public function setName($name)
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get name
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
/**
|
|
* Get id
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* Set travelCountry
|
|
*
|
|
* @param \AppBundle\Entity\TravelCountry $travelCountry
|
|
*
|
|
* @return TravelArrivalPoint
|
|
*/
|
|
public function setTravelCountry(\AppBundle\Entity\TravelCountry $travelCountry = null)
|
|
{
|
|
$this->travelCountry = $travelCountry;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get travelCountry
|
|
*
|
|
* @return \AppBundle\Entity\TravelCountry
|
|
*/
|
|
public function getTravelCountry()
|
|
{
|
|
return $this->travelCountry;
|
|
}
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->departures = new \Doctrine\Common\Collections\ArrayCollection();
|
|
}
|
|
|
|
/**
|
|
* Add departure
|
|
*
|
|
* @param \AppBundle\Entity\TravelDeparturePoint $departure
|
|
*
|
|
* @return TravelArrivalPoint
|
|
*/
|
|
public final function addDeparture(\AppBundle\Entity\TravelDeparturePoint $departure)
|
|
{
|
|
if (!$this->__areDeparturesInitialized__ && isset($this->__initializer__))
|
|
{
|
|
// Imitate proxy behavior, because this method is final and therefore ignored by the proxy
|
|
$this->__initializer__->__invoke($this, 'addDeparture', [$departure]);
|
|
}
|
|
$this->departures[] = $departure;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public $__initializer__;
|
|
|
|
public $__areDeparturesInitialized__ = false;
|
|
|
|
/**
|
|
* Set departures, because the travel date search algorithm already retrieves them at another place. Therefore
|
|
* the proxy must be prevented from loading the entire entity as soon as the manually attached departures are
|
|
* accessed. To achieve the prevention, the accessor methods are "final". They imitate the proxy's behavior, in
|
|
* case they are called and departures haven't been set manually before.
|
|
*
|
|
* @param ArrayCollection $departures
|
|
*
|
|
* @internal
|
|
*/
|
|
public final function __setDepartures($departures)
|
|
{
|
|
$this->__areDeparturesInitialized__ = true;
|
|
if ($departures === null)
|
|
{
|
|
$this->departures = null;
|
|
}
|
|
$this->departures = new ArrayCollection();
|
|
foreach ($departures as $departure)
|
|
{
|
|
$this->departures->add($departure);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Remove departure
|
|
*
|
|
* @param \AppBundle\Entity\TravelDeparturePoint $departure
|
|
*/
|
|
public final function removeDeparture(\AppBundle\Entity\TravelDeparturePoint $departure)
|
|
{
|
|
if (!$this->__areDeparturesInitialized__ && isset($this->__initializer__))
|
|
{
|
|
// Imitate proxy behavior, because this method is final and therefore ignored by the proxy
|
|
$this->__initializer__->__invoke($this, 'removeDeparture', [$departure]);
|
|
}
|
|
$this->departures->removeElement($departure);
|
|
}
|
|
|
|
/**
|
|
* Get departures
|
|
*
|
|
* @return \Doctrine\Common\Collections\Collection|TravelDeparturePoint[]
|
|
*/
|
|
public final function getDepartures()
|
|
{
|
|
if (!$this->__areDeparturesInitialized__ && isset($this->__initializer__))
|
|
{
|
|
// Imitate proxy behavior, because this method is final and therefore ignored by the proxy
|
|
$this->__initializer__->__invoke($this, 'getDeparture', []);
|
|
}
|
|
return $this->departures;
|
|
}
|
|
}
|