Move UserBundle in CoreBundle Remove fosuserbundle use native symfony 5 auth Remove unused sonata codepull/3262/head
parent
fc2db7eb9f
commit
a57d820968
@ -0,0 +1,144 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Entity; |
||||
|
||||
use Doctrine\ORM\Mapping as ORM; |
||||
|
||||
/** |
||||
* @ORM\Entity() |
||||
* @ORM\Table(name="fos_group") |
||||
*/ |
||||
class Group |
||||
{ |
||||
/** |
||||
* @var int |
||||
* |
||||
* @ORM\Column(name="id", type="integer") |
||||
* @ORM\Id |
||||
* @ORM\GeneratedValue(strategy="AUTO") |
||||
*/ |
||||
protected $id; |
||||
|
||||
/** |
||||
* @var string |
||||
* @ORM\Column(name="name", type="string", length=255, nullable=false, unique=true) |
||||
*/ |
||||
protected $name; |
||||
/** |
||||
* @var array |
||||
* @ORM\Column(name="roles", type="array") |
||||
*/ |
||||
protected $roles; |
||||
|
||||
/** |
||||
* @ORM\ManyToMany(targetEntity="Chamilo\CoreBundle\Entity\User", mappedBy="groups") |
||||
*/ |
||||
protected $users; |
||||
|
||||
/** |
||||
* @var string |
||||
* |
||||
* @ORM\Column(name="code", type="string", length=40, nullable=false, unique=true) |
||||
*/ |
||||
protected $code; |
||||
|
||||
public function __construct($name, $roles = array()) |
||||
{ |
||||
$this->name = $name; |
||||
$this->roles = $roles; |
||||
} |
||||
|
||||
public function addRole($role) |
||||
{ |
||||
if (!$this->hasRole($role)) { |
||||
$this->roles[] = strtoupper($role); |
||||
} |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function hasRole($role) |
||||
{ |
||||
return in_array(strtoupper($role), $this->roles, true); |
||||
} |
||||
|
||||
public function getRoles() |
||||
{ |
||||
return $this->roles; |
||||
} |
||||
public function removeRole($role) |
||||
{ |
||||
if (false !== $key = array_search(strtoupper($role), $this->roles, true)) { |
||||
unset($this->roles[$key]); |
||||
$this->roles = array_values($this->roles); |
||||
} |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* @param string $name |
||||
* |
||||
* @return Group |
||||
*/ |
||||
public function setName($name) |
||||
{ |
||||
$this->name = $name; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* @param array $roles |
||||
* |
||||
* @return Group |
||||
*/ |
||||
public function setRoles(array $roles) |
||||
{ |
||||
$this->roles = $roles; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get id. |
||||
* |
||||
* @return int |
||||
*/ |
||||
public function getId() |
||||
{ |
||||
return $this->id; |
||||
} |
||||
|
||||
public function getUsers() |
||||
{ |
||||
return $this->users; |
||||
} |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function getCode() |
||||
{ |
||||
return $this->code; |
||||
} |
||||
|
||||
/** |
||||
* @param string $code |
||||
* |
||||
* @return Group |
||||
*/ |
||||
public function setCode($code) |
||||
{ |
||||
$this->code = $code; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function __toString() |
||||
{ |
||||
return $this->getName() ?: ''; |
||||
} |
||||
} |
@ -1,14 +0,0 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Entity\Manager; |
||||
|
||||
use Sonata\Doctrine\Entity\BaseEntityManager; |
||||
|
||||
/** |
||||
* Class SettingsCurrentRepository. |
||||
*/ |
||||
class SettingsCurrentManager extends BaseEntityManager |
||||
{ |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue