symfony - How to customize configureDatagridFilters in Sonata Admin to use non related mongodb documents -


in mongodb got passenger document, typical item:

{     "_id" : objectid("51efdf818d6b408449000002"),     "createdat" : 1374674817,     "phone" : "222222",     .. } 

i have device document references passenger document, here example:

{     "_id" : objectid("51efdf818d6b408449000001"),     "os" : "android.gcm",     "passenger" : objectid("51efdf818d6b408449000002"),     .. } 

so in other words.. there no way can find out device belonging passenger running query on passenger.. must query on device.

in passengeradmin.php got configure list field definition:

public function configurelistfields(listmapper $listmapper) {     $listmapper         ->addidentifier('name', 'text', array('label' => 'name'))         ->addidentifier('phone', 'text', array('label' => 'phone #'))         ->addidentifier('createdat', 'datetime', array('label' => 'created at'))         ->addidentifier('device.os', 'text', array('label' => 'device os type'))          ..     ; } 

which works fine (i have no idea how sonata managed map device.os passengers.. oh well).

inside configuredatagridfilters return error:

protected function configuredatagridfilters(datagridmapper $datagrid) {     $datagrid->add('device.os'); } 

error:

notice: undefined index: device.os in ../vendor/sonata-project/doctrine-mongodb-admin-bundle/sonata/doctrinemongodbadminbundle/builder/datagridbuilder.php line 60

which guess makes sense.. , if created index nothing returned.. (by way got idea here: see displaying subentity properties

question:

how can customize filter regarding device os version incorporates info related device document. lemme show want done using example (mix of code , pseudocode):

->add('osversion', 'doctrine_mongo_callback', [     'callback' => function ($querybuilder, $alias, $field, $params) {             if ($params['value'] === null) {                 return;             }             // each passengers passenger             // passenger.id = %passengerid%             // grab device has passenger = %passengerid%             // filter device.os == $params['value']      'field_type' => 'choice',     'field_options' => ['choices'=> ['android.gcm'=> "android", "os.ios"=>"ios"]] ]); 

i noticed createquery method of superclass admin can overridden.. seems that globally so, , wouldn't me in specific case.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -