icingaweb2-module-businessp.../library/Businessprocess/Modification/NodeRemoveAction.php

64 lines
1.2 KiB
PHP
Raw Normal View History

2015-03-16 04:08:00 -04:00
<?php
namespace Icinga\Module\Businessprocess\Modification;
use Icinga\Module\Businessprocess\BusinessProcess;
2015-03-16 04:08:00 -04:00
/**
* NodeRemoveAction
*
* Tracks removed nodes
*
* @package Icinga\Module\Businessprocess
*/
2015-03-16 04:08:00 -04:00
class NodeRemoveAction extends NodeAction
{
protected $preserveProperties = array('path');
protected $path;
/**
* @param array $path
* @return $this
*/
public function setPath(array $path)
{
$this->path = $path;
return $this;
}
/**
* @return mixed
*/
public function getPath()
{
return $this->path;
}
/**
* @inheritdoc
*/
2015-03-16 04:08:00 -04:00
public function appliesTo(BusinessProcess $bp)
{
$path = $this->getPath();
if ($path === null) {
return $bp->hasNodeByPath($this->getNodeName(), $this->getPath());
} else {
return $bp->hasNode($this->getNodeName());
}
2015-03-16 04:08:00 -04:00
}
/**
* @inheritdoc
*/
2015-03-16 04:08:00 -04:00
public function applyTo(BusinessProcess $bp)
{
$path = $this->getPath();
if ($path === null) {
$bp->removeNode($this->getNodeName());
} else {
$bp->removeNodeByPath($this->getNodeName(), $this->getPath());
}
2015-03-16 04:08:00 -04:00
}
}