service - Sonata Admin: Use one Admin to show different resultsets -


i have crud admin 1 entity, has property called "type" ... want display in sonata sidebar 3 different entries 3 different types. decided use same admin 3 types , inject type parameter

       admin.type1:           class: bla\blub\typeadmin           tags:             - { name: sonata.admin, manager_type: orm, group: "group", label: "type1", show_in_dashboard: true }           arguments:             - null             - some\test\entity             - null             - ['type1']         admin.type2:           class: bla\blub\typeadmin           tags:             - { name: sonata.admin, manager_type: orm, group: "group", label: "type2", show_in_dashboard: true }           arguments:             - null             - some\test\entity             - null             - ['type2']         admin.type3:           class: bla\blub\typeadmin           tags:             - { name: sonata.admin, manager_type: orm, group: "group", label: "type3", show_in_dashboard: true }           arguments:             - null             - some\test\entity             - null             - ['type3'] 

in admin class override createquery meth

    public function createquery($context = 'list') {     /** @var querybuilder $query */     $query = parent::createquery($context);     $query->andwhere(             $query->expr()->in($query->getrootaliases()[0] . '.type', ':type')         );         $query->setparameter('type', $this->type);         return $query;     } 

but not work. seems sonata set 1 of types every time ... if click on type1 menu entry, type3 injected createquery function ...

can tell me way use 1 admin multiple sidebar entries showing different resultsets? don't want implement multiple admins doing same thing except 1 criteria ...

i tried extend admin 3 "subadmins" , override constructor , set desired type ... end in same result.

i suspect sonata instances 1 admin object , cause problem ...


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -