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

Access transition parameters passed to apply() in TransitionInterface::process #116

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

Comments

@iainmckay
Copy link

Hi, we're integrating Finite in our project and we're implementing our transition logic as concrete implementations of TransitionInterface. Tracing through the source, we've found the the parameters passed to StateMachine::apply() aren't passed to TransitionInterface::process.

Is there a reason for this?
Would a PR be accepted to change this?

@yohang
Copy link
Owner

yohang commented Apr 20, 2016

Hi @iainmckay,

There is a single reason behind this : it implies modification on the TransitionInterface, which is a BC break...

I'll accept a PR for that with pleasure, but it implies a version bump to 2.0, which will not be tagged now as I have some new feature to include at the same time.

The current way to retrieve parameters at transition time is to implement listeners. Or to declare a method of your custom transition class as a transition callback.

@luads
Copy link

luads commented Dec 2, 2016

+1

I'm doing the same concrete implementation of transitions and being able to receive the parameters on the process method would be awesome.

As a fix, I created my own base Transition class that uses resolveProperties to store the values:

protected $propertyValues;

public function resolveProperties(array $properties)
{
    $this->propertyValues = parent::resolveProperties($properties);
    return $this->propertyValues;
}

public function getPropertyValue(string $property)
{
    return $this->propertyValues[$property] ?? null;
}

It depends on resolveProperties being called by the event, but at least I'm able to handle the values on the process method for now.

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

3 participants