How to add multipe ClassAdmin for one object in symfony sonata bundle
I have a class name Admin VenteAdmin.php
with an object 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 mine 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 a different admin class name DevisAdmin.php
with the same object Ventes
but with different listFields, showFields, etc.
How can i do this?
+3
source to share
1 answer
Just define a different service ID, pointing to a new admin class with the same object:
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>" }
+1
source to share