winzou / StateMachineBundle

MIT License
338 stars 43 forks source link

$this not in object context #49

Closed Cathmor closed 5 years ago

Cathmor commented 5 years ago

So was working with Sylius about a year ago really enjoyed your State Machine Bundle's implementation within in. I'm trying to incorporate it into my own project but am running into errors. I'm working with Symfony 4 and have an autowired service that's throwing a '$this not in object context' when I try to use it with the transition callback. But when I use the same service in a controller or command or something, it works fine. Thoughts? Is there a config setting somewhere I need to set?

aguidis commented 5 years ago

I had the same error but I realized that I was using an old release (0.3.1) so first, check if you use a version above 0.4 and then make your service public so the ContainerAwareCallback can fetch the service directly from the container.

winzou commented 5 years ago

@aguidis is right, you should try the version 0.4 that is compatible with Symfony 4. Let us know if it solves your issue. Thanks!

Cathmor commented 5 years ago

Yep, I using 0.3 on Symfony 4. Upgraded and all set. Thanks @aguidis and @winzou!