icingaweb2-module-businessp.../library/Businessprocess/Modification/NodeRemoveAction.php
2016-12-16 19:32:36 +01:00

63 lines
1.2 KiB
PHP

<?php
namespace Icinga\Module\Businessprocess\Modification;
use Icinga\Module\Businessprocess\BusinessProcess;
/**
* NodeRemoveAction
*
* Tracks removed nodes
*
* @package Icinga\Module\Businessprocess
*/
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
*/
public function appliesTo(BusinessProcess $bp)
{
$path = $this->getPath();
if ($path === null) {
return $bp->hasNodeByPath($this->getNodeName(), $this->getPath());
} else {
return $bp->hasNode($this->getNodeName());
}
}
/**
* @inheritdoc
*/
public function applyTo(BusinessProcess $bp)
{
$path = $this->getPath();
if ($path === null) {
$bp->removeNode($this->getNodeName());
} else {
$bp->removeNodeByPath($this->getNodeName(), $this->getPath());
}
}
}