mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
documentation for new options in search
This commit is contained in:
parent
bba2f7214f
commit
b5f346aa8f
@ -100,7 +100,7 @@ The SearchInterface class
|
||||
|
||||
// indicate which domain you support
|
||||
// you may respond TRUE to multiple domain, according to your logic
|
||||
public function supports($domain)
|
||||
public function supports($domain, $format='html')
|
||||
{
|
||||
return 'person' === $domain;
|
||||
}
|
||||
@ -121,7 +121,7 @@ The SearchInterface class
|
||||
// This is where your search logic should be executed.
|
||||
// This method must return an HTML string (a string with HTML tags)
|
||||
// see below about the structure of the $term array
|
||||
public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array())
|
||||
public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array(), $format = 'html')
|
||||
{
|
||||
return $this->container->get('templating')->render('ChillPersonBundle:Person:list.html.twig',
|
||||
array(
|
||||
@ -137,6 +137,17 @@ The SearchInterface class
|
||||
}
|
||||
|
||||
|
||||
Values for :code:`$options`
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
:code:`$options` is an array with the following keys:
|
||||
|
||||
- :code:`SearchInterface::SEARCH_PREVIEW_OPTION` (bool): if the current view is a preview (the first 5 results) or not ;
|
||||
- :code:`SearchInterface::REQUEST_QUERY_PARAMETERS` (bool): some parameters added to the query (under the key :code:`SearchInterface::REQUEST_QUERY_KEY_ADD_PARAMETERS`) and that can be interpreted. Used, for instance, when calling a result in json format when searching for interactive picker form.
|
||||
|
||||
|
||||
|
||||
|
||||
Structure of array `$term`
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@ -161,6 +172,21 @@ The original search would have been : `@person argument1:value argument2:(my val
|
||||
.. warning::
|
||||
The search values are always unaccented.
|
||||
|
||||
Returning a result in json
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The json format is mainly used by "select2" widgets.
|
||||
|
||||
When returning a result in json, the SearchInterface should only return an array with following keys:
|
||||
|
||||
- :code:`more` (bool): if the search has more result than the current page ;
|
||||
- :code:`results` (array): a list of result, where:
|
||||
|
||||
- :code:`text` (string): the text that should be displayed in browser ;
|
||||
- :code:`id` (string): the id of the entity.
|
||||
|
||||
|
||||
|
||||
Register the service
|
||||
--------------------
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user