icingadb-web/application/controllers/CommentController.php
Sukhwinder Dhillon c55f1dceb8 Introduce TicketLinkObjectList and CommentRenderer
TicketLinkObjectList: This class creates object list with ticket links using TicketLinks trait
CommentRenderer: Defines the rendering rules for Comment object
Cleanup css and unused classes
Adjust comment-popup.less
2025-03-28 16:13:16 +01:00

68 lines
1.6 KiB
PHP

<?php
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
namespace Icinga\Module\Icingadb\Controllers;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Icingadb\Common\CommandActions;
use Icinga\Module\Icingadb\Common\Links;
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;
use ipl\Web\Url;
class CommentController extends Controller
{
use CommandActions;
/** @var Comment The comment object */
protected $comment;
public function init()
{
$this->addTitleTab(t('Comment'));
$name = $this->params->getRequired('name');
$query = Comment::on($this->getDb())->with([
'host',
'host.state',
'service',
'service.state',
'service.host',
'service.host.state'
]);
$query->filter(Filter::equal('comment.name', $name));
$this->applyRestrictions($query);
$comment = $query->first();
if ($comment === null) {
throw new NotFoundError(t('Comment not found'));
}
$this->comment = $comment;
}
public function indexAction()
{
$this->addControl(new ObjectHeader($this->comment));
$this->addContent(new CommentDetail($this->comment));
$this->setAutorefreshInterval(10);
}
protected function fetchCommandTargets(): array
{
return [$this->comment];
}
protected function getCommandTargetsUrl(): Url
{
return Links::comment($this->comment);
}
}