Sonataadminbundle: Multiple admin section for same entity

前端 未结 3 796
孤独总比滥情好
孤独总比滥情好 2021-02-01 18:42

I have entity class Page with column type=integer. When I do:

   

        
相关标签:
3条回答
  • 2021-02-01 19:25

    You certainly found your solution, but another way to do this would be to create a parent class and inherit using inheritance mapping. You are then able to have different repository and sonata admin would not work differently.

    0 讨论(0)
  • 2021-02-01 19:33

    I don't have enough reputation to add a comment to the previous answer, but it is missing the following information:

    You also need to define a unique $baseRouteName value in addition to $baseRoutePattern in your admin classes:

    protected $baseRouteName = 'admin_vendor_bundlename_adminclassname';
    
    protected $baseRoutePattern = 'unique-route-pattern';
    

    You only need to do this to one class, but consider doing it in both to keep it clear what's going on.

    0 讨论(0)
  • 2021-02-01 19:34

    Sonata creates routes automatically based on your entity names. So if you have 2 admin classes, there is a conflict. You have to configure different route pattern.

    Add this property to Main\ProgramBundle\Admin\GroupAdmin.php:

    protected $baseRouteName = 'page_group';
    protected $baseRoutePattern = 'page-group';
    
    0 讨论(0)
提交回复
热议问题