Modification: rename $bp to $config

This commit is contained in:
Thomas Gelf 2017-01-11 17:36:32 +01:00
parent c86c2fe151
commit c083b117dd
5 changed files with 24 additions and 24 deletions

View file

@ -42,18 +42,18 @@ abstract class NodeAction
/**
* Every NodeAction must be able to apply itself to a BusinessProcess
*
* @param BpConfig $bp
* @param BpConfig $config
* @return mixed
*/
abstract public function applyTo(BpConfig $bp);
abstract public function applyTo(BpConfig $config);
/**
* Every NodeAction must be able to tell whether it could be applied to a BusinessProcess
*
* @param BpConfig $bp
* @param BpConfig $config
* @return bool
*/
abstract public function appliesTo(BpConfig $bp);
abstract public function appliesTo(BpConfig $config);
/**
* The name of the node this modification applies to

View file

@ -2,8 +2,8 @@
namespace Icinga\Module\Businessprocess\Modification;
use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\BpNode;
class NodeAddChildrenAction extends NodeAction
{
@ -14,21 +14,21 @@ class NodeAddChildrenAction extends NodeAction
/**
* @inheritdoc
*/
public function appliesTo(BpConfig $bp)
public function appliesTo(BpConfig $config)
{
$name = $this->getNodeName();
if (! $bp->hasNode($name)) {
if (! $config->hasNode($name)) {
return false;
}
return $bp->getNode($name) instanceof BpNode;
return $config->getNode($name) instanceof BpNode;
}
/**
* @inheritdoc
*/
public function applyTo(BpConfig $bp)
public function applyTo(BpConfig $config)
{
/** @var BpNode $node */
if (! $this->hasNode()) {

View file

@ -70,15 +70,15 @@ class NodeCreateAction extends NodeAction
/**
* @inheritdoc
*/
public function appliesTo(BpConfig $bp)
public function appliesTo(BpConfig $config)
{
return ! $bp->hasNode($this->getNodeName());
return ! $config->hasNode($this->getNodeName());
}
/**
* @inheritdoc
*/
public function applyTo(BpConfig $bp)
public function applyTo(BpConfig $config)
{
$name = $this->getNodeName();

View file

@ -43,15 +43,15 @@ class NodeModifyAction extends NodeAction
/**
* @inheritdoc
*/
public function appliesTo(BpConfig $bp)
public function appliesTo(BpConfig $config)
{
$name = $this->getNodeName();
if (! $bp->hasNode($name)) {
if (! $config->hasNode($name)) {
return false;
}
$node = $bp->getNode($name);
$node = $config->getNode($name);
foreach ($this->properties as $key => $val) {
$func = 'get' . ucfirst($key);
@ -66,9 +66,9 @@ class NodeModifyAction extends NodeAction
/**
* @inheritdoc
*/
public function applyTo(BpConfig $bp)
public function applyTo(BpConfig $config)
{
$node = $bp->getNode($this->getNodeName());
$node = $config->getNode($this->getNodeName());
foreach ($this->properties as $key => $val) {
$func = 'set' . ucfirst($key);

View file

@ -38,29 +38,29 @@ class NodeRemoveAction extends NodeAction
/**
* @inheritdoc
*/
public function appliesTo(BpConfig $bp)
public function appliesTo(BpConfig $config)
{
$parent = $this->getParentName();
if ($parent === null) {
return $bp->hasNode($this->getNodeName());
return $config->hasNode($this->getNodeName());
} else {
return $bp->hasNode($this->getNodeName()) && $bp->hasNode($this->getParentName()) ;
return $config->hasNode($this->getNodeName()) && $config->hasNode($this->getParentName()) ;
}
}
/**
* @inheritdoc
*/
public function applyTo(BpConfig $bp)
public function applyTo(BpConfig $config)
{
$parent = $this->getParentName();
if ($parent === null) {
$bp->removeNode($this->getNodeName());
$config->removeNode($this->getNodeName());
} else {
$node = $bp->getNode($this->getNodeName());
$node = $config->getNode($this->getNodeName());
$node->removeParent($parent);
if (! $node->hasParents()) {
$bp->removeNode($this->getNodeName());
$config->removeNode($this->getNodeName());
}
}
}