ActionController: provide api to all controllers
This commit is contained in:
parent
c4e5e9dd9c
commit
29206188bf
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Controllers;
|
namespace Icinga\Module\Director\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Director\Core\CoreApi;
|
|
||||||
use Icinga\Module\Director\Core\RestApiClient;
|
|
||||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
|
@ -61,13 +59,4 @@ class ConfigController extends ActionController
|
||||||
array('checksum' => $config->getHexChecksum()))
|
array('checksum' => $config->getHexChecksum()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function api()
|
|
||||||
{
|
|
||||||
$apiconfig = $this->Config()->getSection('api');
|
|
||||||
$client = new RestApiClient($apiconfig->get('address'), $apiconfig->get('port'));
|
|
||||||
$client->setCredentials($apiconfig->get('username'), $apiconfig->get('password'));
|
|
||||||
$api = new CoreApi($client);
|
|
||||||
return $api;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
namespace Icinga\Module\Director\Controllers;
|
namespace Icinga\Module\Director\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
use Icinga\Module\Director\Core\RestApiClient;
|
|
||||||
use Icinga\Module\Director\Core\CoreApi;
|
|
||||||
|
|
||||||
class InspectController extends ActionController
|
class InspectController extends ActionController
|
||||||
{
|
{
|
||||||
|
@ -51,13 +49,4 @@ class InspectController extends ActionController
|
||||||
$this->view->status = $status = $this->api()->getStatus();
|
$this->view->status = $status = $this->api()->getStatus();
|
||||||
print_r($status); exit;
|
print_r($status); exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function api()
|
|
||||||
{
|
|
||||||
$apiconfig = $this->Config()->getSection('api');
|
|
||||||
$client = new RestApiClient($apiconfig->get('address'), $apiconfig->get('port'));
|
|
||||||
$client->setCredentials($apiconfig->get('username'), $apiconfig->get('password'));
|
|
||||||
$api = new CoreApi($client);
|
|
||||||
return $api;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
namespace Icinga\Module\Director\Controllers;
|
namespace Icinga\Module\Director\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
use Icinga\Module\Director\Core\RestApiClient;
|
|
||||||
use Icinga\Module\Director\Core\CoreApi;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class ListController extends ActionController
|
class ListController extends ActionController
|
||||||
|
@ -184,15 +182,6 @@ class ListController extends ActionController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function api()
|
|
||||||
{
|
|
||||||
$apiconfig = $this->Config()->getSection('api');
|
|
||||||
$client = new RestApiClient($apiconfig->get('address'), $apiconfig->get('port'));
|
|
||||||
$client->setCredentials($apiconfig->get('username'), $apiconfig->get('password'));
|
|
||||||
$api = new CoreApi($client);
|
|
||||||
return $api;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function prepareTable($name)
|
protected function prepareTable($name)
|
||||||
{
|
{
|
||||||
$table = $this->loadTable($name)->setConnection($this->db());
|
$table = $this->loadTable($name)->setConnection($this->db());
|
||||||
|
|
|
@ -4,6 +4,8 @@ namespace Icinga\Module\Director\Web\Controller;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Data\Paginatable;
|
use Icinga\Data\Paginatable;
|
||||||
|
use Icinga\Module\Director\Core\RestApiClient;
|
||||||
|
use Icinga\Module\Director\Core\CoreApi;
|
||||||
use Icinga\Module\Director\Db;
|
use Icinga\Module\Director\Db;
|
||||||
use Icinga\Module\Director\Web\Form\FormLoader;
|
use Icinga\Module\Director\Web\Form\FormLoader;
|
||||||
use Icinga\Module\Director\Web\Table\TableLoader;
|
use Icinga\Module\Director\Web\Table\TableLoader;
|
||||||
|
@ -70,6 +72,14 @@ abstract class ActionController extends Controller
|
||||||
return $this->view->tabs;
|
return $this->view->tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function api()
|
||||||
|
{
|
||||||
|
$apiconfig = $this->Config()->getSection('api');
|
||||||
|
$client = new RestApiClient($apiconfig->get('address'), $apiconfig->get('port'));
|
||||||
|
$client->setCredentials($apiconfig->get('username'), $apiconfig->get('password'));
|
||||||
|
$api = new CoreApi($client);
|
||||||
|
return $api;
|
||||||
|
}
|
||||||
|
|
||||||
protected function db()
|
protected function db()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue