icingaweb2-module-businessp.../application/controllers/HostController.php

33 lines
813 B
PHP
Raw Normal View History

2017-12-04 12:05:07 -05:00
<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Businessprocess\IcingaDbObject;
use Icinga\Module\Icingadb\Model\Host;
2017-12-04 12:05:07 -05:00
use Icinga\Web\Url;
use ipl\Stdlib\Filter;
use ipl\Web\Compat\CompatController;
2017-12-04 12:05:07 -05:00
class HostController extends CompatController
2017-12-04 12:05:07 -05:00
{
public function showAction(): void
{
$hostName = $this->params->shift('host');
2017-12-04 12:05:07 -05:00
$query = Host::on(IcingaDbObject::fetchDb());
IcingaDbObject::applyIcingaDbRestrictions($query);
$query->filter(Filter::equal('host.name', $hostName));
$host = $query->first();
$this->params->add('name', $hostName);
2017-12-04 12:05:07 -05:00
if ($host !== null) {
$this->redirectNow(Url::fromPath('icingadb/host')->setParams($this->params));
2017-12-04 12:05:07 -05:00
}
$this->view->host = $hostName;
2017-12-04 12:05:07 -05:00
}
}