diff --git a/src/StackFormation/PreProcessor/Stage/Tree/ExpandCslPort.php b/src/StackFormation/PreProcessor/Stage/Tree/ExpandCslPort.php new file mode 100644 index 0000000..ca091c6 --- /dev/null +++ b/src/StackFormation/PreProcessor/Stage/Tree/ExpandCslPort.php @@ -0,0 +1,43 @@ +parent(1); /* @var $parentRootlineItem RootlineItem */ + $parent = $parentRootlineItem->getValue(); /* @var $parent RecursiveArrayObject */ + + $grandParentRootlineItem = $rootLineReferences->parent(2); /* @var $grandParentRootlineItem RootlineItem */ + $grandParent = $grandParentRootlineItem->getValue(); /* @var $grandParent RecursiveArrayObject */ + + // remove original item + $grandParent->offsetUnset($parentRootlineItem->getKey()); + + // add a new line for every csl item + foreach (explode(',', $value) as $port) { + $newItem = clone $parent; + $newItem->FromPort = $port; + $newItem->ToPort = $port; + $newItem->offsetUnset('Port'); + $grandParent->append($newItem); + } + + return true; // indicate that something has changed + } +}