mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-05-28 04:35:53 -04:00
DirectorDb: do not fail when unconfigured and...
...not use by Controllers
This commit is contained in:
parent
56c5ac0846
commit
2f68489cac
1 changed files with 4 additions and 1 deletions
|
|
@ -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…
Reference in a new issue