Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayLoader Change to Use StateMachine's Accessor Breaks Existing State Machines #117

Open
stephenjwinn opened this issue Apr 18, 2016 · 2 comments

Comments

@stephenjwinn
Copy link

c7a5672

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();
    }
@realshadow
Copy link
Contributor

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

@realshadow
Copy link
Contributor

@stephenjwinn Please see #118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants