mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-07 05:59:35 -05:00
NodeRemoveAction: rework to fit current reality
This commit is contained in:
parent
0d696216e2
commit
9e30be79c6
2 changed files with 38 additions and 4 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue