2013-11-04 15:40:51 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\Models\DDC2775;
|
|
|
|
|
2013-11-04 19:01:05 +04:00
|
|
|
/**
|
|
|
|
* @Entity @Table(name="users")
|
|
|
|
*/
|
2013-11-04 15:40:51 +04:00
|
|
|
class User
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @Id @Column(type="integer")
|
|
|
|
* @GeneratedValue(strategy="AUTO")
|
|
|
|
*/
|
2013-12-14 22:57:53 +04:00
|
|
|
public $id;
|
2013-11-04 15:40:51 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="Role", mappedBy="user", cascade={"all"}, orphanRemoval=true)
|
|
|
|
*/
|
|
|
|
public $roles;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="Authorization", mappedBy="user", cascade={"all"}, orphanRemoval=true)
|
|
|
|
*/
|
|
|
|
public $authorizations;
|
|
|
|
|
|
|
|
public function addRole(Role $role)
|
|
|
|
{
|
|
|
|
$this->roles[] = $role;
|
2013-12-14 22:57:53 +04:00
|
|
|
$role->user = $this;
|
2013-11-04 15:40:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function addAuthorization(Authorization $authorization)
|
|
|
|
{
|
|
|
|
$this->authorizations[] = $authorization;
|
2013-12-14 22:57:53 +04:00
|
|
|
$authorization->user = $this;
|
2013-11-04 15:40:51 +04:00
|
|
|
}
|
|
|
|
}
|