2013-06-03 16:56:08 +02:00
|
|
|
<?php
|
2013-06-07 13:29:11 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-06-03 16:56:08 +02:00
|
|
|
|
|
|
|
namespace Icinga\Protocol\Commandpipe;
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
2013-09-16 14:39:14 +02:00
|
|
|
* Container for comment information that can be send to Icinga's external command pipe
|
2013-06-07 13:29:11 +02:00
|
|
|
*/
|
2013-09-04 16:21:44 +02:00
|
|
|
class Comment
|
2013-06-03 16:56:08 +02:00
|
|
|
{
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
2013-09-04 16:21:44 +02:00
|
|
|
* Whether this comment is persistent or not
|
2013-08-01 17:48:36 +02:00
|
|
|
*
|
2013-06-07 13:29:11 +02:00
|
|
|
* @var bool
|
|
|
|
*/
|
2013-09-04 16:21:44 +02:00
|
|
|
public $persistent;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
2013-09-04 16:21:44 +02:00
|
|
|
* The author of this comment
|
2013-08-01 17:48:36 +02:00
|
|
|
*
|
2013-09-04 16:21:44 +02:00
|
|
|
* @var string
|
2013-06-07 13:29:11 +02:00
|
|
|
*/
|
2013-09-04 16:21:44 +02:00
|
|
|
public $author;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
2013-09-04 16:21:44 +02:00
|
|
|
* The text of this comment
|
2013-08-01 17:48:36 +02:00
|
|
|
*
|
2013-09-04 16:21:44 +02:00
|
|
|
* @var string
|
2013-06-07 13:29:11 +02:00
|
|
|
*/
|
2013-09-04 16:21:44 +02:00
|
|
|
public $content;
|
2013-06-03 16:56:08 +02:00
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
2013-08-01 17:48:36 +02:00
|
|
|
* Create a new comment object
|
|
|
|
*
|
2013-09-04 16:21:44 +02:00
|
|
|
* @param string $author The name of the comment's author
|
|
|
|
* @param string $content The text for this comment
|
|
|
|
* @param bool $persistent Whether this comment should be persistent or not
|
2013-06-07 13:29:11 +02:00
|
|
|
*/
|
2013-09-04 16:21:44 +02:00
|
|
|
public function __construct($author, $content, $persistent = false)
|
2013-06-03 16:56:08 +02:00
|
|
|
{
|
|
|
|
$this->author = $author;
|
2013-09-04 16:21:44 +02:00
|
|
|
$this->content = $content;
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->persistent = $persistent;
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
2013-09-04 16:21:44 +02:00
|
|
|
* Return this comment's properties as list of command parameters
|
2013-08-01 17:48:36 +02:00
|
|
|
*
|
2013-09-04 16:21:44 +02:00
|
|
|
* @param bool $ignorePersistentFlag Whether the persistent flag should be included or not
|
|
|
|
* @return array
|
2013-06-07 13:29:11 +02:00
|
|
|
*/
|
2013-09-16 14:46:18 +02:00
|
|
|
public function getArguments($ignorePersistentFlag = false)
|
2013-06-07 13:29:11 +02:00
|
|
|
{
|
2013-09-04 16:21:44 +02:00
|
|
|
if ($ignorePersistentFlag) {
|
|
|
|
return array($this->author, $this->content);
|
|
|
|
} else {
|
|
|
|
return array($this->persistent ? '1' : '0', $this->author, $this->content);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
}
|
2013-06-07 13:29:11 +02:00
|
|
|
}
|