mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
allow json in search response and abstract interactive loading from select2
This commit is contained in:
@@ -57,9 +57,10 @@ interface SearchInterface
|
||||
* @param int $start the first result (for pagination)
|
||||
* @param int $limit the number of result (for pagination)
|
||||
* @param array $option the options, specific for each search
|
||||
* @param string $format The format for result
|
||||
* @return string, an HTML string
|
||||
*/
|
||||
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');
|
||||
|
||||
/**
|
||||
* we may desactive the search interface by default. in this case,
|
||||
@@ -85,6 +86,6 @@ interface SearchInterface
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function supports($domain);
|
||||
public function supports($domain, $format);
|
||||
|
||||
}
|
||||
|
@@ -157,17 +157,18 @@ class SearchProvider
|
||||
|
||||
/**
|
||||
* search through services which supports domain and give
|
||||
* results as html string
|
||||
* results as an array of resultsfrom different SearchInterface
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param number $start
|
||||
* @param number $limit
|
||||
* @param array $options
|
||||
* @return array of html results
|
||||
* @param string $format
|
||||
* @return array of results from different SearchInterface
|
||||
* @throws UnknowSearchDomainException if the domain is unknow
|
||||
*/
|
||||
public function getSearchResults($pattern, $start = 0, $limit = 50,
|
||||
array $options = array())
|
||||
array $options = array(), $format = 'html')
|
||||
{
|
||||
$terms = $this->parse($pattern);
|
||||
$results = array();
|
||||
@@ -180,7 +181,7 @@ class SearchProvider
|
||||
|
||||
if ($terms['_domain'] !== NULL) {
|
||||
foreach ($sortedSearchServices as $service) {
|
||||
if ($service->supports($terms['_domain'])) {
|
||||
if ($service->supports($terms['_domain'], $format)) {
|
||||
$results[] = $service->renderResult($terms, $start, $limit, $options);
|
||||
}
|
||||
}
|
||||
@@ -203,7 +204,7 @@ class SearchProvider
|
||||
}
|
||||
|
||||
public function getResultByName($pattern, $name, $start = 0, $limit = 50,
|
||||
array $options = array())
|
||||
array $options = array(), $format)
|
||||
{
|
||||
$terms = $this->parse($pattern);
|
||||
$search = $this->getByName($name);
|
||||
@@ -213,7 +214,7 @@ class SearchProvider
|
||||
throw new ParsingException("The domain is not supported for the search name");
|
||||
}
|
||||
|
||||
return $search->renderResult($terms, $start, $limit, $options);
|
||||
return $search->renderResult($terms, $start, $limit, $options, $format);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user