diff --git a/library/Businessprocess/Modification/NodeRemoveAction.php b/library/Businessprocess/Modification/NodeRemoveAction.php index 03bf984..62a48bf 100644 --- a/library/Businessprocess/Modification/NodeRemoveAction.php +++ b/library/Businessprocess/Modification/NodeRemoveAction.php @@ -13,12 +13,39 @@ use Icinga\Module\Businessprocess\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) { - return $bp->hasNode($this->getNodeName()); + $path = $this->getPath(); + if ($path === null) { + return $bp->hasNodeByPath($this->getNodeName(), $this->getPath()); + } else { + return $bp->hasNode($this->getNodeName()); + } } /** @@ -26,6 +53,11 @@ class NodeRemoveAction extends NodeAction */ public function applyTo(BusinessProcess $bp) { - $bp->removeNode($this->getNodeName()); + $path = $this->getPath(); + if ($path === null) { + $bp->removeNode($this->getNodeName()); + } else { + $bp->removeNodeByPath($this->getNodeName(), $this->getPath()); + } } } diff --git a/library/Businessprocess/Modification/ProcessChanges.php b/library/Businessprocess/Modification/ProcessChanges.php index 0fb52ae..a86eecc 100644 --- a/library/Businessprocess/Modification/ProcessChanges.php +++ b/library/Businessprocess/Modification/ProcessChanges.php @@ -99,9 +99,11 @@ class ProcessChanges * * @return $this */ - public function deleteNode(Node $node) + public function deleteNode(Node $node, array $path) { - return $this->push(new NodeRemoveAction($node)); + $action = new NodeRemoveAction($node); + $action->setProperties('path', $path); + return $this->push($action); } /**