Cli\Command: allow other modules to extend this...

...class
This commit is contained in:
Thomas Gelf 2016-09-05 15:55:26 +00:00
parent 73eca56601
commit 138f5d2aed
1 changed files with 4 additions and 1 deletions

View File

@ -5,6 +5,7 @@ namespace Icinga\Module\Director\Cli;
use Icinga\Cli\Command as CliCommand; use Icinga\Cli\Command as CliCommand;
use Icinga\Module\Director\Db; use Icinga\Module\Director\Db;
use Icinga\Module\Director\Objects\IcingaEndpoint; use Icinga\Module\Director\Objects\IcingaEndpoint;
use Icinga\Application\Config;
class Command extends CliCommand class Command extends CliCommand
{ {
@ -74,7 +75,9 @@ class Command extends CliCommand
protected function db() protected function db()
{ {
if ($this->db === null) { if ($this->db === null) {
$resourceName = $this->Config()->get('db', 'resource'); // Hint: not using $this->Config() intentionally. This allows
// CLI commands in other modules to use this as a base class.
$resourceName = Config::module('director')->get('db', 'resource');
if ($resourceName) { if ($resourceName) {
$this->db = Db::fromResourceName($resourceName); $this->db = Db::fromResourceName($resourceName);
} else { } else {