icingaweb2-module-director/application/controllers/IndexController.php

52 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2015-10-20 22:34:04 +02:00
namespace Icinga\Module\Director\Controllers;
2016-03-13 23:48:22 +01:00
use Exception;
use Icinga\Module\Director\Db\Migrations;
class IndexController extends DashboardController
{
public function indexAction()
{
$this->view->dashboards = array();
2016-04-22 11:19:54 +02:00
if ($this->Config()->get('db', 'resource')) {
$migrations = new Migrations($this->db());
if (! $migrations->hasSchema() || !$this->hasDeploymentEndpoint()) {
$this->showKickstartForm();
} elseif ($migrations->hasPendingMigrations()) {
$this->view->form = $this
->loadForm('applyMigrations')
->setMigrations($migrations)
->handleRequest();
parent::indexAction();
} else {
parent::indexAction();
}
2016-04-22 11:19:54 +02:00
} else {
$this->showKickstartForm();
2016-04-22 11:19:54 +02:00
}
$this->setViewScript('dashboard/index');
2016-04-22 14:31:41 +02:00
}
protected function showKickstartForm()
2016-04-22 15:51:38 +02:00
{
$this->singleTab($this->translate('Kickstart'));
$this->view->form = $this->loadForm('kickstart')->handleRequest();
2016-04-22 11:19:54 +02:00
}
protected function hasDeploymentEndpoint()
{
try {
$this->view->hasDeploymentEndpoint = $this->db()->hasDeploymentEndpoint();
} catch (Exception $e) {
return false;
2015-12-18 10:51:38 +01:00
}
return $this->view->hasDeploymentEndpoint;
}
}