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

63 lines
1.6 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;
use Icinga\Module\Director\Forms\ApplyMigrationsForm;
class IndexController extends DashboardController
{
protected $hasDeploymentEndpoint;
public function indexAction()
{
if ($this->Config()->get('db', 'resource')) {
$migrations = new Migrations($this->db());
if ($migrations->hasSchema()) {
if (!$this->hasDeploymentEndpoint()) {
$this->showKickstartForm(false);
}
} else {
$this->showKickstartForm();
return;
}
if ($migrations->hasPendingMigrations()) {
2017-06-22 02:09:31 +02:00
$this->content()->prepend(
ApplyMigrationsForm::load()
->setMigrations($migrations)
->handleRequest()
);
}
parent::indexAction();
2016-04-22 11:19:54 +02:00
} else {
$this->showKickstartForm();
2016-04-22 11:19:54 +02:00
}
2016-04-22 14:31:41 +02:00
}
protected function showKickstartForm($showTab = true)
2016-04-22 15:51:38 +02:00
{
if ($showTab) {
$this->addSingleTab($this->translate('Kickstart'));
}
$this->content()->prepend(
$this->loadForm('kickstart')->handleRequest()
);
2016-04-22 11:19:54 +02:00
}
protected function hasDeploymentEndpoint()
{
try {
$this->hasDeploymentEndpoint = $this->db()->hasDeploymentEndpoint();
} catch (Exception $e) {
return false;
2015-12-18 10:51:38 +01:00
}
return $this->hasDeploymentEndpoint;
}
}