StateMachineBundle icon indicating copy to clipboard operation
StateMachineBundle copied to clipboard

Disabling callbacks based on Expression language

Open tristanbes opened this issue 8 years ago • 4 comments

Hello,

Right now we can disable a callback via enabled: false. Wouldn't be awesome if we could put Expressions using the ExpressionEngine instead of a boolean ?

Use case: feature flags This way we could enable/disable callbacks with business logic instead of adding the logic itself inside the callback code wenever possible.

callbacks:
    my_callback:
        ...
        enabled: "object.getSettings().hasFeature('email_enabled')"

tristanbes avatar Mar 16 '16 12:03 tristanbes

Hello,

I'm not a big fan of putting too much business logic in config files. But I see an interesting use case for dynamically disable a third-party callback, instead of writing a new callback with a if to call the third-party callback.

You can already use container parameters in the disabled key, why is that not enough?

winzou avatar Mar 17 '16 01:03 winzou

Because we have multi-tenant application (for example X shops running on the same database and codebase). So each X stores has different configuration/features that are not dumped into the container

tristanbes avatar Mar 17 '16 08:03 tristanbes

@winzou Would you merge such feature if we open a PR? :)

pjedrzejewski avatar Jun 28 '16 07:06 pjedrzejewski

@pjedrzejewski Definitely, that's a really interesting feature actually. Should not be complicated to implement.

winzou avatar Jun 28 '16 09:06 winzou