2015-03-16 04:08:00 -04:00
|
|
|
<?php
|
|
|
|
|
|
2016-11-23 06:27:55 -05:00
|
|
|
namespace Icinga\Module\Businessprocess\Modification;
|
|
|
|
|
|
|
|
|
|
use Icinga\Module\Businessprocess\BusinessProcess;
|
2015-03-16 04:08:00 -04:00
|
|
|
|
2016-11-22 15:11:26 -05:00
|
|
|
/**
|
|
|
|
|
* NodeRemoveAction
|
|
|
|
|
*
|
|
|
|
|
* Tracks removed nodes
|
|
|
|
|
*
|
|
|
|
|
* @package Icinga\Module\Businessprocess
|
|
|
|
|
*/
|
2015-03-16 04:08:00 -04:00
|
|
|
class NodeRemoveAction extends NodeAction
|
|
|
|
|
{
|
2016-12-16 13:32:36 -05:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 15:11:26 -05:00
|
|
|
/**
|
|
|
|
|
* @inheritdoc
|
|
|
|
|
*/
|
2015-03-16 04:08:00 -04:00
|
|
|
public function appliesTo(BusinessProcess $bp)
|
|
|
|
|
{
|
2016-12-16 13:32:36 -05:00
|
|
|
$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
|
|
|
}
|
|
|
|
|
|
2016-11-22 15:11:26 -05:00
|
|
|
/**
|
|
|
|
|
* @inheritdoc
|
|
|
|
|
*/
|
2015-03-16 04:08:00 -04:00
|
|
|
public function applyTo(BusinessProcess $bp)
|
|
|
|
|
{
|
2016-12-16 13:32:36 -05:00
|
|
|
$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
|
|
|
}
|
|
|
|
|
}
|