From d885f96c7a81a3345b6993d5bebd3bb38c25f6c4 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Fri, 7 May 2021 01:34:23 +0200 Subject: [PATCH] Update doc --- .../recipe_overwrite_admin_configuration.rst | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/docs/cookbook/recipe_overwrite_admin_configuration.rst b/docs/cookbook/recipe_overwrite_admin_configuration.rst index a974a92fd66..4329e0d0e7d 100644 --- a/docs/cookbook/recipe_overwrite_admin_configuration.rst +++ b/docs/cookbook/recipe_overwrite_admin_configuration.rst @@ -5,16 +5,17 @@ Sometimes you might want to overwrite some Admin settings from vendors. This recipe will explain how to achieve this operation. However, keep in mind this operation is quite dangerous and might break code. -From the configuration file, you can add a new section named ``admin_services`` +From the configuration file, you can add a new section named ``default_admin_services`` with the following templates: .. code-block:: yaml sonata_admin: - admin_services: + default_admin_services: # service configuration model_manager: sonata.admin.manager.orm data_source: sonata.admin.data_source.orm + field_description_factory: sonata.admin.field_description_factory.orm form_contractor: sonata.admin.builder.orm_form show_builder: sonata.admin.builder.orm_show list_builder: sonata.admin.builder.orm_list @@ -22,19 +23,29 @@ with the following templates: translator: translator configuration_pool: sonata.admin.pool route_generator: sonata.admin.route.default_generator - validator: validator security_handler: sonata.admin.security.handler menu_factory: knp_menu.factory route_builder: sonata.admin.route.path_info label_translator_strategy: sonata.admin.label.strategy.native + pager_type: default - # templates configuration - templates: - # view templates - view: - user_block: mytemplate.twig.html - # form related theme templates => this feature need to be implemented by the Persistency layer of each Admin Bundle - form: ['MyTheme.twig.html', 'MySecondTheme.twig.html'] - filter: ['MyTheme.twig.html', 'MySecondTheme.twig.html'] +With these settings you will be able to change default services and templates used by the admin instances. -With these settings you will be able to change default services and templates used by the admin instance. +If you need to override the service of a specific admin, you can do it during the service declaration: + +.. code-block:: yaml + + # config/services.yaml + + services: + admin.blog_post: + class: App\Admin\BlogPostAdmin + arguments: [~, App\Entity\BlogPost, ~] + tags: + - name: sonata.admin + manager_type: orm + label: 'Blog post' + label_translator_strategy: sonata.admin.label.strategy.native + route_builder: sonata.admin.route.path_info + pager_type: simple + # and so on