mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-27 15:54:03 +02:00
DirectorDb: do not fail when unconfigured and...
...not use by Controllers
This commit is contained in:
parent
56c5ac0846
commit
2f68489cac
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Web\Controller\Extension;
|
||||
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Module\Director\Db;
|
||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||
|
||||
trait DirectorDb
|
||||
{
|
||||
@ -21,12 +22,14 @@ trait DirectorDb
|
||||
$resourceName = $this->Config()->get('db', 'resource');
|
||||
if ($resourceName) {
|
||||
$this->db = Db::fromResourceName($resourceName);
|
||||
} else {
|
||||
} elseif ($this instanceof ActionController) {
|
||||
if ($this->getRequest()->isApiRequest()) {
|
||||
throw new ConfigurationError('Icinga Director is not correctly configured');
|
||||
} else {
|
||||
$this->redirectNow('director');
|
||||
}
|
||||
} else {
|
||||
throw new ConfigurationError('Icinga Director is not correctly configured');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user