Finite
Finite copied to clipboard
ArrayLoader Change to Use StateMachine's Accessor Breaks Existing State Machines
https://github.com/yohang/Finite/commit/c7a5672377695cdf65cd5f9a3372c18d0f02d7c1
The func hasStateAccessor() always evaluates to true because the StateMachine constructor inits the stateAccessor to a new PropertyPathStateAccessor...It's never null. So this doesn't work:
if (!$stateMachine->hasStateAccessor()) {
** // I AM NEVER GOING TO LAND HERE.**
$stateMachine->setStateAccessor(new PropertyPathStateAccessor($this->config['property_path']));
}
This wouldn't be a problem, except the StateMachine constructor doesn't pass in a configuration property_path param to the PropertyPathStateAccessor. So the StateAccessor I have is not good. It doesn't ever grab the state.
public function __construct(
$object = null,
EventDispatcherInterface $dispatcher = null,
StateAccessorInterface $stateAccessor = null
) {
$this->object = $object;
$this->dispatcher = $dispatcher ?: new EventDispatcher();
$this->stateAccessor = $stateAccessor ?: new PropertyPathStateAccessor();
}
Changing stateAccessor in constructor to $this->stateAccessor = $stateAccessor; should propably fix the issue unless there is some reason for initialization in constructor that I am not aware of.
I will look into it in the morning
@stephenjwinn Please see #118