winzou / StateMachineBundle

MIT License
338 stars 43 forks source link

Extra arguments when using callbacks #41

Closed hookewin closed 6 years ago

hookewin commented 6 years ago

hi, i have a question on how to pass extra arguments when using callbacks, like i have the follow configuration:

callbacks:
    after:
         sylius_process_cart:
                    on: ["select_shipping", "address", "select_payment", "skip_shipping", "skip_payment"]
                    do: ["@sylius.order_processing.order_processor", "process"]
                    args: ["object"]

then, in the args field i want to add another args(is an object), pls tell me how can i finish this operation? thx.

winzou commented 6 years ago

Hello,

What argument would you like to inject? You can inject container parameters as usual: args: ["object", "%parameter%"].

But I would recommend to inject it at service construction (i.e. in the service constructor, not in the callback call).