1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/tests/Doctrine/Tests/Models/Cache/Traveler.php

91 lines
1.6 KiB
PHP
Raw Normal View History

2013-02-14 02:42:13 +04:00
<?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);
}
}