2011-07-28 12:46:38 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\Models\Legacy;
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Entity
|
|
|
|
* @Table(name="legacy_users")
|
|
|
|
*/
|
|
|
|
class LegacyUser
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @Id
|
|
|
|
* @GeneratedValue
|
|
|
|
* @Column(name="iUserId", type="integer", nullable=false)
|
|
|
|
*/
|
2011-07-28 14:25:23 +04:00
|
|
|
public $_id;
|
2011-07-28 12:46:38 +04:00
|
|
|
/**
|
|
|
|
* @Column(name="sUsername", type="string", length=255, unique=true)
|
|
|
|
*/
|
2011-07-28 14:25:23 +04:00
|
|
|
public $_username;
|
2011-07-28 12:46:38 +04:00
|
|
|
/**
|
2011-10-30 01:58:09 +04:00
|
|
|
* @Column(type="string", length=255, name="name")
|
2011-07-28 12:46:38 +04:00
|
|
|
*/
|
2011-07-28 14:25:23 +04:00
|
|
|
public $_name;
|
2011-07-28 12:46:38 +04:00
|
|
|
/**
|
2011-07-28 14:25:23 +04:00
|
|
|
* @OneToMany(targetEntity="LegacyArticle", mappedBy="_user")
|
2011-07-28 12:46:38 +04:00
|
|
|
*/
|
2011-07-28 14:25:23 +04:00
|
|
|
public $_articles;
|
2011-07-28 12:46:38 +04:00
|
|
|
/**
|
2011-07-28 14:25:23 +04:00
|
|
|
* @OneToMany(targetEntity="LegacyUserReference", mappedBy="_source", cascade={"remove"})
|
2011-07-28 12:46:38 +04:00
|
|
|
*/
|
2011-07-28 14:25:23 +04:00
|
|
|
public $_references;
|
2011-07-28 12:46:38 +04:00
|
|
|
/**
|
2011-07-28 14:25:23 +04:00
|
|
|
* @ManyToMany(targetEntity="LegacyCar", inversedBy="_users", cascade={"persist", "merge"})
|
2011-07-29 11:35:59 +04:00
|
|
|
* @JoinTable(name="legacy_users_cars",
|
2011-07-28 12:46:38 +04:00
|
|
|
* joinColumns={@JoinColumn(name="iUserId", referencedColumnName="iUserId")},
|
|
|
|
* inverseJoinColumns={@JoinColumn(name="iCarId", referencedColumnName="iCarId")}
|
|
|
|
* )
|
|
|
|
*/
|
2011-07-28 14:25:23 +04:00
|
|
|
public $_cars;
|
2011-07-28 12:46:38 +04:00
|
|
|
public function __construct() {
|
2011-07-28 14:25:23 +04:00
|
|
|
$this->_articles = new ArrayCollection;
|
|
|
|
$this->_references = new ArrayCollection;
|
|
|
|
$this->_cars = new ArrayCollection;
|
2011-07-28 12:46:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getId() {
|
2011-07-28 14:25:23 +04:00
|
|
|
return $this->_id;
|
2011-07-28 12:46:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getUsername() {
|
2011-07-28 14:25:23 +04:00
|
|
|
return $this->_username;
|
2011-07-28 12:46:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function addArticle(LegacyArticle $article) {
|
2011-07-28 14:25:23 +04:00
|
|
|
$this->_articles[] = $article;
|
2011-07-28 12:46:38 +04:00
|
|
|
$article->setAuthor($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addReference($reference)
|
|
|
|
{
|
2011-07-28 14:25:23 +04:00
|
|
|
$this->_references[] = $reference;
|
2011-07-28 12:46:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function references()
|
|
|
|
{
|
2011-07-28 14:25:23 +04:00
|
|
|
return $this->_references;
|
2011-07-28 12:46:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function addCar(LegacyCar $car) {
|
2011-07-28 14:25:23 +04:00
|
|
|
$this->_cars[] = $car;
|
2011-07-28 12:46:38 +04:00
|
|
|
$car->addUser($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCars() {
|
2011-07-28 14:25:23 +04:00
|
|
|
return $this->_cars;
|
2011-07-28 12:46:38 +04:00
|
|
|
}
|
|
|
|
}
|