UserBackend: Allow to only pass a backend's name

This commit is contained in:
Johannes Meyer 2015-06-05 10:40:47 +02:00
parent ee2462a6b2
commit 127489ca20
1 changed files with 11 additions and 1 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Authentication\User; namespace Icinga\Authentication\User;
use Icinga\Application\Config;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Data\ConfigObject; use Icinga\Data\ConfigObject;
@ -106,8 +107,17 @@ class UserBackend
* *
* @throws ConfigurationError * @throws ConfigurationError
*/ */
public static function create($name, ConfigObject $backendConfig) public static function create($name, ConfigObject $backendConfig = null)
{ {
if ($backendConfig === null) {
$authConfig = Config::app('authentication');
if ($authConfig->hasSection($name)) {
$backendConfig = $authConfig->getSection($name);
} else {
throw new ConfigurationError('User backend "%s" does not exist', $name);
}
}
if ($backendConfig->name !== null) { if ($backendConfig->name !== null) {
$name = $backendConfig->name; $name = $backendConfig->name;
} }