2011-12-14 22:28:01 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\Models\DDC964;
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @MappedSuperclass
|
|
|
|
*/
|
|
|
|
class DDC964User
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2012-04-14 09:10:44 +04:00
|
|
|
* @Id
|
2011-12-14 22:28:01 +04:00
|
|
|
* @GeneratedValue
|
2012-04-14 09:10:44 +04:00
|
|
|
* @Column(type="integer", name="user_id", length=150)
|
2011-12-14 22:28:01 +04:00
|
|
|
*/
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
/**
|
2012-04-14 09:10:44 +04:00
|
|
|
* @Column(name="user_name", nullable=true, unique=false, length=250)
|
2011-12-14 22:28:01 +04:00
|
|
|
*/
|
|
|
|
protected $name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var ArrayCollection
|
|
|
|
*
|
|
|
|
* @ManyToMany(targetEntity="DDC964Group", inversedBy="users", cascade={"persist", "merge", "detach"})
|
|
|
|
* @JoinTable(name="ddc964_users_groups",
|
|
|
|
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
|
|
|
|
* inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")}
|
|
|
|
* )
|
|
|
|
*/
|
|
|
|
protected $groups;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var DDC964Address
|
|
|
|
*
|
|
|
|
* @ManyToOne(targetEntity="DDC964Address", cascade={"persist", "merge"})
|
|
|
|
* @JoinColumn(name="address_id", referencedColumnName="id")
|
|
|
|
*/
|
|
|
|
protected $address;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $name
|
|
|
|
*/
|
|
|
|
public function __construct($name = null)
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
$this->groups = new ArrayCollection;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public function getId()
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $name
|
|
|
|
*/
|
|
|
|
public function setName($name)
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param DDC964Group $group
|
|
|
|
*/
|
|
|
|
public function addGroup(DDC964Group $group)
|
|
|
|
{
|
|
|
|
$this->groups->add($group);
|
|
|
|
$group->addUser($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return ArrayCollection
|
|
|
|
*/
|
|
|
|
public function getGroups()
|
|
|
|
{
|
|
|
|
return $this->groups;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return DDC964Address
|
|
|
|
*/
|
|
|
|
public function getAddress()
|
|
|
|
{
|
|
|
|
return $this->address;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param DDC964Address $address
|
|
|
|
*/
|
|
|
|
public function setAddress(DDC964Address $address)
|
|
|
|
{
|
|
|
|
$this->address = $address;
|
|
|
|
}
|
2012-02-02 06:57:39 +04:00
|
|
|
|
|
|
|
public static function loadMetadata($metadata)
|
|
|
|
{
|
|
|
|
$metadata->mapField(array(
|
|
|
|
'id' => true,
|
|
|
|
'fieldName' => 'id',
|
|
|
|
'type' => 'integer',
|
2012-04-14 09:10:44 +04:00
|
|
|
'columnName' => 'user_id',
|
|
|
|
'length' => 150,
|
2012-02-02 06:57:39 +04:00
|
|
|
));
|
|
|
|
$metadata->mapField(array(
|
2012-04-14 09:10:44 +04:00
|
|
|
'fieldName' => 'name',
|
|
|
|
'type' => 'string',
|
|
|
|
'columnName'=> 'user_name',
|
|
|
|
'nullable' => true,
|
|
|
|
'unique' => false,
|
|
|
|
'length' => 250,
|
2012-02-02 06:57:39 +04:00
|
|
|
));
|
|
|
|
|
|
|
|
$metadata->mapManyToOne(array(
|
|
|
|
'fieldName' => 'address',
|
|
|
|
'targetEntity' => 'DDC964Address',
|
|
|
|
'cascade' => array('persist','merge'),
|
|
|
|
'joinColumn' => array('name'=>'address_id', 'referencedColumnMame'=>'id'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$metadata->mapManyToMany(array(
|
|
|
|
'fieldName' => 'groups',
|
|
|
|
'targetEntity' => 'DDC964Group',
|
|
|
|
'inversedBy' => 'users',
|
|
|
|
'cascade' => array('persist','merge','detach'),
|
|
|
|
'joinTable' => array(
|
|
|
|
'name' => 'ddc964_users_groups',
|
|
|
|
'joinColumns' => array(array(
|
|
|
|
'name'=>'user_id',
|
|
|
|
'referencedColumnName'=>'id',
|
|
|
|
)),
|
|
|
|
'inverseJoinColumns'=>array(array(
|
|
|
|
'name'=>'group_id',
|
|
|
|
'referencedColumnName'=>'id',
|
|
|
|
))
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO);
|
|
|
|
}
|
2011-12-14 22:28:01 +04:00
|
|
|
}
|