mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
UserGroupBackend: Add missing and fix existing method documentation
This commit is contained in:
parent
847c02ed8e
commit
c9dcddb134
@ -6,7 +6,6 @@ namespace Icinga\Authentication\UserGroup;
|
|||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\IcingaException;
|
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,16 +14,16 @@ use Icinga\User;
|
|||||||
abstract class UserGroupBackend
|
abstract class UserGroupBackend
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Name of the backend
|
* The name of this backend
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the backend name
|
* Set this backend's name
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
@ -35,9 +34,9 @@ abstract class UserGroupBackend
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the backend name
|
* Return this backend's name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
@ -45,42 +44,36 @@ abstract class UserGroupBackend
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a user group backend
|
* Create and return a UserGroupBackend with the given name and given configuration applied to it
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param ConfigObject $backendConfig
|
* @param ConfigObject $backendConfig
|
||||||
*
|
*
|
||||||
* @return DbUserGroupBackend|IniUserGroupBackend
|
* @return UserGroupBackend
|
||||||
* @throws ConfigurationError If the backend configuration is invalid
|
*
|
||||||
|
* @throws ConfigurationError
|
||||||
*/
|
*/
|
||||||
public static function create($name, ConfigObject $backendConfig)
|
public static function create($name, ConfigObject $backendConfig)
|
||||||
{
|
{
|
||||||
if ($backendConfig->name !== null) {
|
if ($backendConfig->name !== null) {
|
||||||
$name = $backendConfig->name;
|
$name = $backendConfig->name;
|
||||||
}
|
}
|
||||||
if (($backendType = $backendConfig->backend) === null) {
|
|
||||||
|
if (! ($backendType = strtolower($backendConfig->backend))) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Configuration for user group backend \'%s\' is missing the \'backend\' directive',
|
'Configuration for user group backend "%s" is missing the \'backend\' directive',
|
||||||
$name
|
$name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$backendType = strtolower($backendType);
|
|
||||||
if (($resourceName = $backendConfig->resource) === null) {
|
if ($backendConfig->resource === null) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Configuration for user group backend \'%s\' is missing the \'resource\' directive',
|
'Configuration for user group backend "%s" is missing the \'resource\' directive',
|
||||||
$name
|
$name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$resourceName = strtolower($resourceName);
|
$resource = ResourceFactory::create($backendConfig->resource);
|
||||||
try {
|
|
||||||
$resource = ResourceFactory::create($resourceName);
|
|
||||||
} catch (IcingaException $e) {
|
|
||||||
throw new ConfigurationError(
|
|
||||||
'Can\'t create user group backend \'%s\'. An exception was thrown: %s',
|
|
||||||
$resourceName,
|
|
||||||
$e
|
|
||||||
);
|
|
||||||
}
|
|
||||||
switch ($backendType) {
|
switch ($backendType) {
|
||||||
case 'db':
|
case 'db':
|
||||||
$backend = new DbUserGroupBackend($resource);
|
$backend = new DbUserGroupBackend($resource);
|
||||||
@ -90,11 +83,13 @@ abstract class UserGroupBackend
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Can\'t create user group backend \'%s\'. Invalid backend type \'%s\'.',
|
'Configuration for user group backend "%s" defines an invalid backend type.'
|
||||||
|
. ' Backend type "%s" is not supported',
|
||||||
$name,
|
$name,
|
||||||
$backendType
|
$backendType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$backend->setName($name);
|
$backend->setName($name);
|
||||||
return $backend;
|
return $backend;
|
||||||
}
|
}
|
||||||
@ -102,7 +97,7 @@ abstract class UserGroupBackend
|
|||||||
/**
|
/**
|
||||||
* Get the groups the given user is a member of
|
* Get the groups the given user is a member of
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user