Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/ProcessEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ private function doProceed(Token $token)
}

$first = true;
/** @var Transition $transition */
foreach ($transitions as $transition) {
$this->log('Next transition: %s -> %s',
$transition->getFrom() ? $transition->getFrom()->getLabel() : 'start',
Expand All @@ -185,12 +186,20 @@ private function doProceed(Token $token)
$first = false;
$token->addTransition(TokenTransition::createFor($transition, $tokenTransition->getWeight()));

foreach ($transition->getTokenValues() as $key => $value) {
set_value($token, $key, $value);
}

$this->transition($token);
} else {
$newToken = $this->forkProcessToken($token);
$newToken->addTransition(TokenTransition::createFor($transition, $transition->getWeight()));
$newToken->getCurrentTransition()->setWeight($tokenTransition->getWeight());

foreach ($transition->getTokenValues() as $key => $value) {
set_value($newToken, $key, $value);
}

$this->transition($newToken);
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/Transition.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ class Transition
*/
private $_process;

/**
* @var array
*/
private $tokenValues;

public function __construct()
{
$this->setId(Uuid::generate());
$this->setWeight(1);
$this->setAsync(false);
$this->setActive(true);

$this->tokenValues = [];
}

/**
Expand Down Expand Up @@ -166,4 +173,14 @@ public function getState(): string
{
return get_value($this, 'state');
}

public function setTokenValues(array $values): void
{
$this->tokenValues = $values;
}

public function getTokenValues(): array
{
return $this->tokenValues;
}
}
2 changes: 1 addition & 1 deletion src/Visual/BuildDigraphScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function build(Graph $graph): string
}

}
//dump($digraph->render());die;

return $digraph->render();
}
}
22 changes: 12 additions & 10 deletions src/Visual/VisualizeFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function display(Graph $graph)
private function createVertex(Graph $graph, Node $node)
{
/** @var Options $options */
$options = get_object($node, 'visual', Options::class) ?: new Options();
$options = get_object($node, 'option', Options::class) ?: new Options();
$vertex = $graph->createVertex($node->getId());
$vertex->setAttribute('graphviz.label', $node->getLabel() ?: $node->getId());
$vertex->setAttribute('graphviz.id', $node->getId());
Expand All @@ -131,6 +131,9 @@ private function createVertex(Graph $graph, Node $node)
case 'gateway':
$shape = 'diamond';
break;
case 'event':
$shape = 'circle';
break;
default:
$shape = 'box';
}
Expand All @@ -157,7 +160,7 @@ private function createStartTransition(Graph $graph, Vertex $from, Transition $t

$edge->setAttribute('alom.graphviz', [
'label' => $transition->getName(),
'id' => $transition->getId(),
'id' => sprintf('%s->%s', $from->getId(), $to->getId()),
]);
}

Expand All @@ -171,13 +174,15 @@ private function createEndTransition(Graph $graph, Vertex $to, Transition $trans
$edge = $from->createEdgeTo($to);
}

$edge->setAttribute('graphviz.label', $transition->getName());
$edge->setAttribute('graphviz.id', $transition->getId());
$edge->setAttribute('pvm.transition_id', $transition->getId());
$id = sprintf('%s->%s', $from->getId(), $to->getId());

$edge->setAttribute('graphviz.label', $id);
$edge->setAttribute('graphviz.id', $id);
$edge->setAttribute('pvm.transition_id', $id);

$edge->setAttribute('alom.graphviz', [
'label' => $transition->getName(),
'id' => $transition->getId(),
'id' => $id,
]);
}

Expand All @@ -189,10 +194,7 @@ private function createMiddleTransition(Graph $graph, Transition $transition)
$edge = $from->createEdgeTo($to);
$edge->setAttribute('pvm.transition_id', $transition->getId());
$edge->setAttribute('graphviz.id', $transition->getId());
$edge->setAttribute(
'graphviz.label',
$transition->getName()
);
$edge->setAttribute('graphviz.label', $transition->getName());

$edge->setAttribute('alom.graphviz', [
'id' => $transition->getId(),
Expand Down