icingadb-web/application/controllers/CommentController.php

54 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2019-11-04 09:51:28 -05:00
<?php
2020-03-13 03:38:01 -04:00
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
2019-11-04 19:07:30 -05:00
namespace Icinga\Module\Icingadb\Controllers;
2019-11-04 09:51:28 -05:00
use Icinga\Exception\NotFoundError;
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Model\Comment;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\CommentDetail;
use Icinga\Module\Icingadb\Widget\Detail\ObjectHeader;
use ipl\Stdlib\Filter;
2019-11-04 09:51:28 -05:00
class CommentController extends Controller
{
/** @var Comment The comment object */
protected $comment;
public function init()
{
$this->addTitleTab(t('Comment'));
2019-11-04 09:51:28 -05:00
$name = $this->params->getRequired('name');
2019-11-04 09:51:28 -05:00
$query = Comment::on($this->getDb())->with([
'host',
'host.state',
'service',
'service.state',
'service.host',
'service.host.state'
]);
$query->filter(Filter::equal('comment.name', $name));
2019-11-04 09:51:28 -05:00
$this->applyRestrictions($query);
2019-11-04 09:51:28 -05:00
$comment = $query->first();
if ($comment === null) {
throw new NotFoundError(t('Comment not found'));
2019-11-04 09:51:28 -05:00
}
$this->comment = $comment;
}
2019-12-16 08:20:11 -05:00
public function indexAction()
{
$this->addControl(new ObjectHeader($this->comment));
2019-12-16 08:20:11 -05:00
$this->addContent(new CommentDetail($this->comment));
2019-12-16 08:20:11 -05:00
$this->setAutorefreshInterval(10);
}
2019-11-04 09:51:28 -05:00
}