2012-06-04 23:56:46 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\Models\Quote;
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Entity
|
|
|
|
* @Table(name="`quote-user`")
|
|
|
|
*/
|
|
|
|
class User
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @Id
|
|
|
|
* @GeneratedValue
|
|
|
|
* @Column(type="integer", name="`user-id`")
|
|
|
|
*/
|
|
|
|
public $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(type="string", name="`user-name`")
|
|
|
|
*/
|
|
|
|
public $name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="Phone", mappedBy="user", cascade={"persist"})
|
|
|
|
*/
|
|
|
|
public $phones;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @JoinColumn(name="`address-id`", referencedColumnName="`address-id`")
|
2012-06-12 00:41:00 +04:00
|
|
|
* @OneToOne(targetEntity="Address", mappedBy="user", cascade={"persist"}, fetch="EAGER")
|
2012-06-04 23:56:46 +04:00
|
|
|
*/
|
|
|
|
public $address;
|
|
|
|
|
|
|
|
/**
|
2012-06-27 07:14:29 +04:00
|
|
|
* @ManyToMany(targetEntity="Group", inversedBy="users", cascade={"all"})
|
2012-06-04 23:56:46 +04:00
|
|
|
* @JoinTable(name="`quote-users-groups`",
|
|
|
|
* joinColumns={
|
|
|
|
* @JoinColumn(
|
|
|
|
* name="`user-id`",
|
2012-06-06 20:14:20 +04:00
|
|
|
* referencedColumnName="`user-id`"
|
|
|
|
* )
|
2012-06-04 23:56:46 +04:00
|
|
|
* },
|
|
|
|
* inverseJoinColumns={
|
|
|
|
* @JoinColumn(
|
|
|
|
* name="`group-id`",
|
|
|
|
* referencedColumnName="`group-id`"
|
|
|
|
* )
|
|
|
|
* }
|
|
|
|
* )
|
|
|
|
*/
|
|
|
|
public $groups;
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->phones = new ArrayCollection;
|
|
|
|
$this->groups = new ArrayCollection;
|
|
|
|
}
|
|
|
|
|
2012-06-12 00:41:00 +04:00
|
|
|
|
|
|
|
public function getPhones()
|
|
|
|
{
|
|
|
|
return $this->phones;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAddress()
|
|
|
|
{
|
|
|
|
return $this->address;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getGroups()
|
|
|
|
{
|
|
|
|
return $this->groups;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setAddress(Address $address) {
|
|
|
|
if ($this->address !== $address) {
|
|
|
|
$this->address = $address;
|
|
|
|
$address->setUser($this);
|
|
|
|
}
|
|
|
|
}
|
2012-06-04 23:56:46 +04:00
|
|
|
}
|