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.
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, andFileExistenceResource
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.