dunglas / DunglasActionBundle

Symfony controllers, redesigned
https://dunglas.fr/2016/01/dunglasactionbundle-symfony-controllers-redesigned/
MIT License
256 stars 14 forks source link

The compiler pass does not register resources to reload the container for added or removed controller classes #21

Closed stof closed 8 years ago

stof commented 8 years ago

The auto-discovery of controller services means that adding a new service or removing it needs to register container resources. Otherwise, devs will have to clear their cache manually each time they create a new controller (I even think that the routing cache will be reloaded automatically, but referencing a service not created by your bundle yet, making the experience even more confusing).

You should use DirectoryResource to handle the case of newly added classes, and FileExistenceResource to handle the case of removal (no need to handle the case of edition, as your compiler pass does not rely on the content of the file but only on the class name). Note that the case of the removal may already work fine as a side-effect of the fact that the service you define is auto-wired.

dunglas commented 8 years ago

Thank you for the report @stof!

This is now fixed. You was right, using FileExistenceResource is useless because AutowirePass already add the class to the list of watched resources.