Skip to content

Commit

Permalink
ArrayLoader should respect state machines state accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
realshadow committed Apr 1, 2016
1 parent dc53d48 commit 1097d63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Finite/Loader/ArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public function load(StateMachineInterface $stateMachine)
$this->callbackBuilderFactory = new CallbackBuilderFactory();
}

$stateMachine->setStateAccessor(new PropertyPathStateAccessor($this->config['property_path']));
if (!$stateMachine->hasStateAccessor()) {
$stateMachine->setStateAccessor(new PropertyPathStateAccessor($this->config['property_path']));
}

$stateMachine->setGraph($this->config['graph']);

$this->loadStates($stateMachine);
Expand Down
8 changes: 8 additions & 0 deletions src/Finite/StateMachine/StateMachine.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ public function setStateAccessor(StateAccessorInterface $stateAccessor)
$this->stateAccessor = $stateAccessor;
}

/**
* {@inheritdoc}
*/
public function hasStateAccessor()
{
return null !== $this->stateAccessor;
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Finite/StateMachine/StateMachineInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ public function getDispatcher();
*/
public function setStateAccessor(StateAccessorInterface $stateAccessor);

/**
* @return bool
*/
public function hasStateAccessor();

/**
* @param string $graph
*/
Expand Down

0 comments on commit 1097d63

Please sign in to comment.