mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 16:54:06 +02:00
CliCommand: provide api helper
This commit is contained in:
parent
19a92b1bef
commit
e250c7c6f6
@ -4,11 +4,29 @@ namespace Icinga\Module\Director\Cli;
|
||||
|
||||
use Icinga\Cli\Command as CliCommand;
|
||||
use Icinga\Module\Director\Db;
|
||||
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
||||
|
||||
class Command extends CliCommand
|
||||
{
|
||||
protected $db;
|
||||
|
||||
private $api;
|
||||
|
||||
protected function api($endpointName = null)
|
||||
{
|
||||
if ($this->api === null) {
|
||||
if ($endpointName === null) {
|
||||
$endpoint = $this->db()->getDeploymentEndpoint();
|
||||
} else {
|
||||
$endpoint = IcingaEndpoint::load($endpointName, $this->db());
|
||||
}
|
||||
|
||||
$this->api = $endpoint->api();
|
||||
}
|
||||
|
||||
return $this->api;
|
||||
}
|
||||
|
||||
protected function db()
|
||||
{
|
||||
if ($this->db === null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user