Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by
  1. Home
  2. Documentation
  3. Bundles
  4. SonataAdminBundle
  5. Overwrite Admin Configuration

Overwrite Admin Configuration

Edit this page

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 default_admin_services with the following templates:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sonata_admin:
    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
        datagrid_builder:           sonata.admin.builder.orm_datagrid
        translator:                 translator
        configuration_pool:         sonata.admin.pool
        route_generator:            sonata.admin.route.default_generator
        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

With these settings you will be able to change default services and templates used by the admin instances.

If you need to override the service of a specific admin, you can do it during the service declaration:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# config/services.yaml

services:
    admin.blog_post:
        class: App\Admin\BlogPostAdmin
        tags:
            - name: sonata.admin
              model_class: App\Entity\BlogPost
              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
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    Code consumes server resources. Blackfire tells you how

    Code consumes server resources. Blackfire tells you how

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Version:

    Symfony footer

    Avatar of Temuri Takalandze, a Symfony contributor

    Thanks Temuri Takalandze (@abgeo) for being a Symfony contributor

    1 commit • 2 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • What is Symfony?
      • Symfony at a Glance
      • Symfony Components
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • Symfony Community
      • SymfonyConnect
      • Events & Meetups
      • Projects using Symfony
      • Contributors
      • Symfony Jobs
      • Backers
      • Code of Conduct
      • Downloads Stats
      • Support
    • Blog

      • All Blog Posts
      • A Week of Symfony
      • Case Studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Living on the edge
      • Releases
      • Security Advisories
      • Symfony Insight
      • Twig
      • SensioLabs Blog
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Powered by

    Follow Symfony