mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 05:44:36 +02:00
monitoring: Reduce complexity of the CommentController
This commit is contained in:
parent
9cf56410e9
commit
6ff7882fc0
@ -16,7 +16,7 @@ class CommentController extends Controller
|
||||
/**
|
||||
* The fetched comment
|
||||
*
|
||||
* @var stdClass
|
||||
* @var object
|
||||
*/
|
||||
protected $comment;
|
||||
|
||||
@ -43,19 +43,18 @@ class CommentController extends Controller
|
||||
))->where('comment_internal_id', $commentId);
|
||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||
|
||||
$this->comment = $query->getQuery()->fetchRow();
|
||||
if ($this->comment === false) {
|
||||
if (false === $this->comment = $query->getQuery()->fetchRow()) {
|
||||
$this->httpNotFound($this->translate('Comment not found'));
|
||||
}
|
||||
|
||||
$this->getTabs()->add(
|
||||
'comment',
|
||||
array(
|
||||
'icon' => 'comment',
|
||||
'label' => $this->translate('Comment'),
|
||||
'title' => $this->translate(
|
||||
'Display detailed information about a comment.'
|
||||
),
|
||||
'icon' => 'comment',
|
||||
'label' => $this->translate('Comment'),
|
||||
'url' =>'monitoring/comments/show'
|
||||
)
|
||||
)->activate('comment')->extend(new DashboardAction());
|
||||
@ -66,37 +65,19 @@ class CommentController extends Controller
|
||||
*/
|
||||
public function showAction()
|
||||
{
|
||||
$listCommentsLink = Url::fromPath('monitoring/list/comments')
|
||||
->setQueryString('comment_type=(comment|ack)');
|
||||
|
||||
$this->view->comment = $this->comment;
|
||||
|
||||
if ($this->hasPermission('monitoring/command/comment/delete')) {
|
||||
$this->view->delCommentForm = $this->createDelCommentForm();
|
||||
$this->view->delCommentForm->populate(
|
||||
array(
|
||||
'redirect' => $listCommentsLink,
|
||||
$listUrl = Url::fromPath('monitoring/list/comments')->setQueryString('comment_type=(comment|ack)');
|
||||
$form = new DeleteCommentCommandForm();
|
||||
$form
|
||||
->populate(array(
|
||||
'redirect' => $listUrl,
|
||||
'comment_id' => $this->comment->id,
|
||||
'comment_is_service' => isset($this->comment->service_description)
|
||||
)
|
||||
);
|
||||
))
|
||||
->handleRequest();
|
||||
$this->view->delCommentForm = $form;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a command form to delete a single comment
|
||||
*
|
||||
* @return DeleteCommentsCommandForm
|
||||
*/
|
||||
private function createDelCommentForm()
|
||||
{
|
||||
$this->assertPermission('monitoring/command/comment/delete');
|
||||
|
||||
$delCommentForm = new DeleteCommentCommandForm();
|
||||
$delCommentForm->setAction(
|
||||
Url::fromPath('monitoring/comment/show')
|
||||
->setParam('comment_id', $this->comment->id)
|
||||
);
|
||||
$delCommentForm->handleRequest();
|
||||
return $delCommentForm;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user