简体   繁体   中英

how to add multipe ClassAdmin for one entity in symfony sonata bundle

I have a Admin class name VenteAdmin.php with entity Vente :

class VentesAdmin extends AbstractAdmin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        // ... 
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {

    }

    protected function configureListFields(ListMapper $listMapper)
    {

    }

    protected function configureShowFields(ShowMapper $showMapper)
    {

    }
}

this is my services.yml :

services:
    admin.facture:
        class: AppBundle\Admin\VentesAdmin
        arguments: [~, AppBundle\Entity\Ventes, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, group: Ventes, label: Facture, icon: "<i class=\"fa fa-file-text\"></i>" }

and I want to add another admin class name DevisAdmin.php by the same entity Ventes but with other listFields, showFields, etc.

How can I do this?

Just make sure to define a different servide ID, pointing to the new admin class with the same entity:

services:
    admin.devis:
        class: AppBundle\Admin\DevisAdmin
        arguments: [~, AppBundle\Entity\Ventes, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, group: Devis, label: Devis, icon: "<i class=\"fa fa-file-text\"></i>" }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM