61 lines
1.1 KiB
PHP
61 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Catalyst\AuthBundle\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
// base User class
|
|
abstract class User
|
|
{
|
|
// NOTE: doctrine annotations for roles have to be declared on the child class
|
|
protected $roles;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $enabled;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->roles = new ArrayCollection();
|
|
$this->enabled = true;
|
|
}
|
|
|
|
// array of string roles, needed by symfony
|
|
public function getRoles()
|
|
{
|
|
$str_roles = [];
|
|
foreach ($this->roles as $role)
|
|
$str_roles[] = $role->getID();
|
|
|
|
return $str_roles;
|
|
}
|
|
|
|
public function getRoleObjects()
|
|
{
|
|
return $this->roles;
|
|
}
|
|
|
|
public function addRole(Role $role)
|
|
{
|
|
$this->roles->add($role);
|
|
return $this;
|
|
}
|
|
|
|
public function clearRoles()
|
|
{
|
|
$this->roles->clear();
|
|
return $this;
|
|
}
|
|
|
|
public function setEnabled($enabled = true)
|
|
{
|
|
$this->enabled = $enabled;
|
|
return $this;
|
|
}
|
|
|
|
public function isEnabled()
|
|
{
|
|
return $this->enabled;
|
|
}
|
|
}
|