icingaweb2-module-businessp.../application/controllers/HostController.php
Sukhwinder Dhillon d17c4501b2 Use same view script in monitoring and icingadb for Access Denied message
- Host|ServiceController: The extended class `CompatController` has its own tabs. Therefore, set the view script tabs to null
  to avoid creating tabs twice.
- View-scripts: Add a condition to create tabs only when the `monitoring` backend (ido[Host|Service]Controller) is used.
2026-01-13 08:52:01 +01:00

37 lines
1 KiB
PHP

<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Businessprocess\IcingaDbObject;
use Icinga\Module\Icingadb\Model\Host;
use Icinga\Web\Url;
use ipl\Html\HtmlString;
use ipl\Stdlib\Filter;
use ipl\Web\Compat\CompatController;
class HostController extends CompatController
{
public function showAction(): void
{
$hostName = $this->params->shift('host');
$query = Host::on(IcingaDbObject::fetchDb());
IcingaDbObject::applyIcingaDbRestrictions($query);
$query->filter(Filter::equal('host.name', $hostName));
$host = $query->first();
$this->params->add('name', $hostName);
if ($host !== null) {
$this->redirectNow(Url::fromPath('icingadb/host')->setParams($this->params));
}
$this->getTabs()->disableLegacyExtensions();
$this->view->host = $hostName;
$this->view->tabs = null; // compatController already creates tabs
$this->addContent(HtmlString::create($this->view->render('ido-host/show.phtml')));
}
}