{"action":"created","issue":{"url":"https://api.github.com/repos/sonata-project/SonataAdminSearchBundle/issues/11","labels_url":"https://api.github.com/repos/sonata-project/SonataAdminSearchBundle/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/sonata-project/SonataAdminSearchBundle/issues/11/comments","events_url":"https://api.github.com/repos/sonata-project/SonataAdminSearchBundle/issues/11/events","html_url":"https://github.com/sonata-project/SonataAdminSearchBundle/pull/11","id":75645818,"number":11,"title":"Implement callback filter.","user":{"login":"magedan","id":3216058,"avatar_url":"https://avatars.githubusercontent.com/u/3216058?v=3","gravatar_id":"","url":"https://api.github.com/users/magedan","html_url":"https://github.com/magedan","followers_url":"https://api.github.com/users/magedan/followers","following_url":"https://api.github.com/users/magedan/following{/other_user}","gists_url":"https://api.github.com/users/magedan/gists{/gist_id}","starred_url":"https://api.github.com/users/magedan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magedan/subscriptions","organizations_url":"https://api.github.com/users/magedan/orgs","repos_url":"https://api.github.com/users/magedan/repos","events_url":"https://api.github.com/users/magedan/events{/privacy}","received_events_url":"https://api.github.com/users/magedan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-05-12T15:44:30Z","updated_at":"2015-05-22T08:11:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sonata-project/SonataAdminSearchBundle/pulls/11","html_url":"https://github.com/sonata-project/SonataAdminSearchBundle/pull/11","diff_url":"https://github.com/sonata-project/SonataAdminSearchBundle/pull/11.diff","patch_url":"https://github.com/sonata-project/SonataAdminSearchBundle/pull/11.patch"},"body":"This will allow to use \"elastica_callback\" as a filter type (fix for #8).\r\n\r\nCallback can modify original filter query. Here is the usage sample:\r\n\r\n``` php\r\n<?php\r\n\r\nnamespace AppBundle\\Admin;\r\n\r\nuse Sonata\\AdminBundle\\Admin\\Admin;\r\nuse Sonata\\AdminBundle\\Datagrid\\DatagridMapper;\r\nuse Sonata\\AdminBundle\\Datagrid\\ProxyQueryInterface;\r\n\r\nclass MyAdmin extends Admin\r\n{\r\n    // ...\r\n    // Fields to be shown on filter forms\r\n    protected function configureDatagridFilters(DatagridMapper $datagridMapper)\r\n    {\r\n        $datagridMapper\r\n            ->add('name', 'elastica_callback', [\r\n                'callback' => function (ProxyQueryInterface $query, $alias, $field, $data) {\r\n                    if (!$data || !is_array($data) || !array_key_exists('value', $data)) {\r\n                        return;\r\n                    }\r\n\r\n                    $data['value'] = trim($data['value']);\r\n\r\n                    if (strlen($data['value']) == 0) {\r\n                        return;\r\n                    }\r\n\r\n                    $queryBuilder = new \\Elastica\\Query\\Builder();\r\n\r\n                    // you can use any Elastica query configuration provided by FOSElasticaBundle\r\n                    $queryBuilder\r\n                        ->fieldOpen('multi_match')\r\n                            ->field('query', $data['value'])\r\n                            ->field('fields', ['name', 'name.std'])\r\n                            ->field('operator', 'and')\r\n                        ->fieldClose();\r\n\r\n                    $query->addMust($queryBuilder);\r\n                }\r\n            ])\r\n        ;\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/sonata-project/SonataAdminSearchBundle/issues/comments/104560281","html_url":"https://github.com/sonata-project/SonataAdminSearchBundle/pull/11#issuecomment-104560281","issue_url":"https://api.github.com/repos/sonata-project/SonataAdminSearchBundle/issues/11","id":104560281,"user":{"login":"magedan","id":3216058,"avatar_url":"https://avatars.githubusercontent.com/u/3216058?v=3","gravatar_id":"","url":"https://api.github.com/users/magedan","html_url":"https://github.com/magedan","followers_url":"https://api.github.com/users/magedan/followers","following_url":"https://api.github.com/users/magedan/following{/other_user}","gists_url":"https://api.github.com/users/magedan/gists{/gist_id}","starred_url":"https://api.github.com/users/magedan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magedan/subscriptions","organizations_url":"https://api.github.com/users/magedan/orgs","repos_url":"https://api.github.com/users/magedan/repos","events_url":"https://api.github.com/users/magedan/events{/privacy}","received_events_url":"https://api.github.com/users/magedan/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T08:11:07Z","updated_at":"2015-05-22T08:11:07Z","body":"Ping @rande (I've added very basic documentation)."}}