1
0
mirror of synced 2024-12-14 23:26:04 +03:00
doctrine2/tests/Doctrine/Tests/Models/Cache/Traveler.php
2013-12-16 11:05:04 -05:00

91 lines
1.6 KiB
PHP

<?php
namespace Doctrine\Tests\Models\Cache;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Cache
* @Entity
* @Table("cache_traveler")
*/
class Traveler
{
const CLASSNAME = __CLASS__;
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
protected $id;
/**
* @Column
*/
protected $name;
/**
* @Cache()
* @OneToMany(targetEntity="Travel", mappedBy="traveler", cascade={"persist", "remove"}, orphanRemoval=true)
*
* @var \Doctrine\Common\Collections\Collection
*/
public $travels;
/**
* @param string $name
*/
public function __construct($name)
{
$this->name = $name;
$this->travels = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getTravels()
{
return $this->travels;
}
/**
* @param \Doctrine\Tests\Models\Cache\Travel $item
*/
public function addTravel(Travel $item)
{
if ( ! $this->travels->contains($item)) {
$this->travels->add($item);
}
if ($item->getTraveler() !== $this) {
$item->setTraveler($this);
}
}
/**
* @param \Doctrine\Tests\Models\Cache\Travel $item
*/
public function removeTravel(Travel $item)
{
$this->travels->removeElement($item);
}
}