Skip to content

Commit

Permalink
Implement demo mode in inclusive gateways
Browse files Browse the repository at this point in the history
  • Loading branch information
caleeli committed Jun 28, 2024
1 parent 4847eeb commit b2dab47
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/ProcessMaker/Nayra/Bpmn/ConditionedTransition.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
class ConditionedTransition implements TransitionInterface, ConditionedTransitionInterface
{
use TransitionTrait;
use ForceGatewayTransitionTrait;

/**
* @var callable
Expand All @@ -29,6 +30,15 @@ class ConditionedTransition implements TransitionInterface, ConditionedTransitio
*/
public function assertCondition(TokenInterface $token = null, ExecutionInstanceInterface $executionInstance = null)
{
// If debug mode is enabled, the transition is triggered only if it is selected
if ($executionInstance && $this->shouldDebugTriggerThisTransition($executionInstance)) {
return true;
}
// If debug mode is enabled, the transition is not triggered if it is not selected
if ($executionInstance && $this->shouldDebugSkipThisTransition($executionInstance)) {
return false;
}

$condition = $this->condition;
$dataStore = $executionInstance ? $executionInstance->getDataStore()
: $this->getOwnerProcess()->getEngine()->getDataStore();
Expand Down
5 changes: 4 additions & 1 deletion src/ProcessMaker/Nayra/Bpmn/InclusiveGatewayTransition.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\TransitionInterface;
use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;
use ProcessMaker\Nayra\Engine\DemoModeTrait;

/**
* Transition rule for a inclusive gateway.
*/
class InclusiveGatewayTransition implements TransitionInterface
{
use TransitionTrait;
use PauseOnGatewayTransitionTrait;

/**
* Initialize the tokens consumed property, the Inclusive Gateway consumes
Expand All @@ -34,7 +36,8 @@ protected function initExclusiveGatewayTransition()
*/
public function assertCondition(TokenInterface $token = null, ExecutionInstanceInterface $executionInstance = null)
{
return true;
// Execution is paused if Engine is in demo mode and the gateway choose is not selected
return !$this->shouldPauseGatewayTransition($executionInstance);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/ProcessMaker/Nayra/Bpmn/PauseOnGatewayTransitionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ function shouldPauseGatewayTransition(ExecutionInstanceInterface $executionInsta
$engine = $executionInstance->getEngine();
$demoMode = $engine->isDemoMode();
$gateway = $this->getOwner();
error_log(
$gateway->getId()
. '=' . json_encode($demoMode && !$engine->getSelectedDemoFlow($gateway))
);
return $demoMode && !$engine->getSelectedDemoFlow($gateway);
}
}

0 comments on commit b2dab47

Please sign in to comment.