问题
I need to add an action to clear symfony2 cache in sonata admin which will be used for example when JMS translations are updated. I would like to know how to create a custom action not related to entity in sonata admin and how to execute clear cache command from it when the admin will click on the corresponding custom link.
回答1:
You may create an action in very straight-forward Symfony way - create a route, make a common controller for this route. Or call the action in any other way Symfony offers.
Sonata admin bundle just extend your application with it's CRUD controller, which you can use. But any other controllers created in normal way are working as well.
来源:https://stackoverflow.com/questions/38221948/how-to-create-a-custom-action-not-related-to-entity-from-sonata-admin