From a366db79c00e982f4706c972d3517b60f1dd14df Mon Sep 17 00:00:00 2001 From: Willem Oostendorp Date: Mon, 20 Jun 2016 12:15:47 +0200 Subject: [PATCH 1/3] Added transition to the guard call --- src/Finite/StateMachine/StateMachine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Finite/StateMachine/StateMachine.php b/src/Finite/StateMachine/StateMachine.php index 47caad8..de4776a 100644 --- a/src/Finite/StateMachine/StateMachine.php +++ b/src/Finite/StateMachine/StateMachine.php @@ -147,7 +147,7 @@ public function can($transition, array $parameters = array()) { $transition = $transition instanceof TransitionInterface ? $transition : $this->getTransition($transition); - if (null !== $transition->getGuard() && !call_user_func($transition->getGuard(), $this)) { + if (null !== $transition->getGuard() && !call_user_func($transition->getGuard(), $this, $transition)) { return false; } From 65da8be43a272552b18895c2e96ff46997f40a24 Mon Sep 17 00:00:00 2001 From: Willem Oostendorp Date: Thu, 23 Jun 2016 10:06:09 +0200 Subject: [PATCH 2/3] Set a new stateAccessor when the property path isn't finiteState, even when the stateMachine already has a stateAccessor --- src/Finite/Loader/ArrayLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Finite/Loader/ArrayLoader.php b/src/Finite/Loader/ArrayLoader.php index 12755b6..b06f2e8 100644 --- a/src/Finite/Loader/ArrayLoader.php +++ b/src/Finite/Loader/ArrayLoader.php @@ -69,7 +69,7 @@ public function load(StateMachineInterface $stateMachine) $this->callbackBuilderFactory = new CallbackBuilderFactory(); } - if (!$stateMachine->hasStateAccessor()) { + if (!$stateMachine->hasStateAccessor() || $this->config['property_path'] != 'finiteState') { $stateMachine->setStateAccessor(new PropertyPathStateAccessor($this->config['property_path'])); } From f8efd50aeb296e277e35385c5fb92ca140c7e03c Mon Sep 17 00:00:00 2001 From: Willem Oostendorp Date: Mon, 27 Jun 2016 12:35:18 +0200 Subject: [PATCH 3/3] Added parameters to guard call --- src/Finite/StateMachine/StateMachine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Finite/StateMachine/StateMachine.php b/src/Finite/StateMachine/StateMachine.php index de4776a..159189b 100644 --- a/src/Finite/StateMachine/StateMachine.php +++ b/src/Finite/StateMachine/StateMachine.php @@ -147,7 +147,7 @@ public function can($transition, array $parameters = array()) { $transition = $transition instanceof TransitionInterface ? $transition : $this->getTransition($transition); - if (null !== $transition->getGuard() && !call_user_func($transition->getGuard(), $this, $transition)) { + if (null !== $transition->getGuard() && !call_user_func($transition->getGuard(), $this, $transition, $parameters)) { return false; }