Closed phillipsnick closed 8 years ago
Why do you need to set the states on the object? The statemachine is responsible for managing the states and transitions, it can also manage your properties.
By default, properties are only accessible for the current state, see : http://finite.readthedocs.org/en/latest/examples/basic_graph.html#current-state.
If you really want to retrieves all properties (and all states), you can retrieve a specific state with getState($name)
https://github.com/yohang/Finite/blob/master/src/Finite/StateMachine/StateMachine.php#L237 and the whole state names with getStates()
https://github.com/yohang/Finite/blob/master/src/Finite/StateMachine/StateMachine.php#L264.
Thanks, makes sense.
I currently use this library with Symfony and define some properties for each state. But it's impossible to access these.
Controller code:
Without access to this I'd have to define all my states twice, which would only make maintenance more difficult.
I previously added a bit of a hack in to get round this as I was in a hurry: https://github.com/phillipsnick/Finite/commit/477f9ba152f3c6e837e1b7c093ea12bbcd39f4ab
Is there any reason why this isn't accessible?