public function addRole($role, $accessInherits = null)
{
if (is_string($role)) {
$role = new Role($role, ucwords($role) . ' Role');
}
if (!$role instanceof RoleInterface) {
throw new Exception('Role must be either an string or implement RoleInterface');
}
$roles = $this->getCollection('roles');
$exists = $roles->count(['name' => $role->getName()]);
if (!$exists) {
$roles->insert(['name' => $role->getName(), 'description' => $role->getDescription()]);
$this->getCollection('accessList')->insert(['roles_name' => $role->getName(), 'resources_name' => '*', 'access_name' => '*', 'allowed' => $this->_defaultAccess]);
}
if ($accessInherits) {
return $this->addInherit($role->getName(), $accessInherits);
}
return true;
}