Skip to content

Commit

Permalink
Improve up downtime command form properties
Browse files Browse the repository at this point in the history
Use a flag instead of a enumeration in delete downtime command form, to remove needless boilerplate.

refs #8624
  • Loading branch information
majentsch committed May 7, 2015
1 parent b35dd4d commit ffd12e3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
Expand Up @@ -21,7 +21,7 @@ public function init()
$this->setAttrib('class', 'inline');
}

/**
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::createElements() For the method documentation.
*/
Expand Down
Expand Up @@ -10,46 +10,38 @@
*/
class DeleteDowntimeCommand extends IcingaCommand
{
/**
* Downtime for a host
*/
const DOWNTIME_TYPE_HOST = 'host';

/**
* Downtime for a service
*/
const DOWNTIME_TYPE_SERVICE = 'service';

/**
* ID of the downtime that is to be deleted
*
* @var int
*/
protected $downtimeId;

/**
* If the command affects a service downtime
*
* @var type
* @var boolean
*/
protected $downtimeType = self::DOWNTIME_TYPE_HOST;
protected $isService = false;

/**
* Set the downtime type, either host or service
* Set if this command affects a service
*
* @param string $type the downtime type
* @param type $value
*/
public function setDowntimeType($type)
public function setIsService($value = true)
{
$this->downtimeType = $type;
$this->isService = (bool) $value;
}

/**
*
* Return whether the command affects a service
*
* @return type
*/
public function getDowntimeType()
public function getIsService()
{
return $this->downtimeType;
return $this->isService;
}

/**
Expand Down
Expand Up @@ -332,14 +332,9 @@ public function renderDeleteComment(DeleteCommentCommand $command)

public function renderDeleteDowntime(DeleteDowntimeCommand $command)
{
if ($command->getDowntimeType() === 'host') {
$commandString = 'DEL_HOST_DOWNTIME';
} else {
$commandString = 'DEL_SVC_DOWNTIME';
}
return sprintf(
'%s;%u',
$commandString,
$command->getIsService() ? 'DEL_SVC_DOWNTIME' : 'DEL_HOST_DOWNTIME',
$command->getDowntimeId()
);
}
Expand Down

0 comments on commit ffd12e3

Please sign in to comment.