rolfvreijdenberger / izzum-statemachine

A superior finite state machine library for php >= 5.3 including php 7
MIT License
64 stars 13 forks source link

multiple callables #10

Closed clindh closed 7 years ago

clindh commented 8 years ago

Rules and Command can be chained using comma. How about also allowing callables to be chained like that?

As callables can be anonymous functions, splitting on comma would cause problems - so how about passing an array of callables instead?

["mycommands::createInvitation","function(...) { .... }"]

Just loop the array and call these callables in turn.

Parsing into and passing an array like that may not be possible/practical for some of the loaders, but that's up to each loader to support it or not then.

rolfvreijdenberger commented 7 years ago

this can also be done by having a callable that wraps the other callables, reusing them. The same can be said about commands (these can wrap and use other rules) but this is existing logic and writing a new class is (subjectively) a little more work than writing a new callable.

But seeing this is not blocking what you want to do (use multiple pieces of logic) it makes no sense at this point to introduce the extra complexity

clindh commented 7 years ago

Ok. FYI: my idea was to allow for defining new machines without writing any PHP-code - piecing together actions from a toolbox of callables. And also make the FSM schema more self-describing (i use PlantUML). But I wrote my own loader to handle this outside Izzum, so that worked out OK.