From 32f50c85cf682783c074feb6649f0109f9fec8a2 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 3 Jan 2017 11:35:09 +0100 Subject: [PATCH] Node: add helpers related to deletion --- library/Businessprocess/Node.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/library/Businessprocess/Node.php b/library/Businessprocess/Node.php index 51f37cb..0d3794d 100644 --- a/library/Businessprocess/Node.php +++ b/library/Businessprocess/Node.php @@ -288,11 +288,38 @@ abstract class Node return count($this->parents) > 0; } + public function hasParentName($name) + { + foreach ($this->getParents() as $parent) { + if ($parent->getName() === $name) { + return true; + } + } + + return false; + } + + public function removeParent($name) + { + $this->parents = array_filter( + $this->parents, + function (BpNode $parent) use ($name) { + return $parent->getName() !== $name; + } + ); + } + public function getParents() { return $this->parents; } + public function getPaths() + { + // TODO! -> for delete etc + return $this->parents; + } + protected function stateToSortState($state) { if (array_key_exists($state, $this->stateToSortStateMap)) {