mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
The search controller return a subset of the 5 first results. If the user want to see more, the services implementing SearchInterface should add a link "see more", and make use of the Pagination API to paginate.
91 lines
2.9 KiB
PHP
91 lines
2.9 KiB
PHP
<?php
|
|
|
|
|
|
/*
|
|
*
|
|
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Search;
|
|
|
|
/**
|
|
* This interface must be implemented on services which provide search results.
|
|
*
|
|
* @todo : write doc and add a link to documentation
|
|
*
|
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
*
|
|
*/
|
|
interface SearchInterface
|
|
{
|
|
|
|
const SEARCH_PREVIEW_OPTION = '_search_preview';
|
|
|
|
/**
|
|
* return the result in a html string. The string will be inclued (as raw)
|
|
* into a global view.
|
|
*
|
|
* The global view may be :
|
|
* {% for result as resultsFromDifferentSearchInterface %}
|
|
* {{ result|raw }}
|
|
* {% endfor %}
|
|
*
|
|
* **available options** :
|
|
* - SEARCH_PREVIEW_OPTION (boolean) : if renderResult should return a "preview" of
|
|
* the results. In this case, a subset of results should be returned, and,
|
|
* if the query return more results, a button "see all results" should be
|
|
* displayed at the end of the list.
|
|
*
|
|
* **Interaction between `start` and `limit` and pagination : you should
|
|
* take only the given parameters into account; the results from pagination
|
|
* should be ignored. (Most of the time, it should be the same).
|
|
*
|
|
* @param array $terms the string to search
|
|
* @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
|
|
* @return string, an HTML string
|
|
*/
|
|
public function renderResult(array $terms, $start=0, $limit=50, array $options = array());
|
|
|
|
/**
|
|
* we may desactive the search interface by default. in this case,
|
|
* the search will be launch and rendered only with "advanced search"
|
|
*
|
|
* this may be activated/desactived from bundle definition in config.yml
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function isActiveByDefault();
|
|
|
|
/**
|
|
* the order in which the results will appears in the global view
|
|
*
|
|
* (this may be eventually defined in config.yml)
|
|
*
|
|
* @return int
|
|
*/
|
|
public function getOrder();
|
|
|
|
/**
|
|
* indicate if the implementation supports the given domain
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function supports($domain);
|
|
|
|
}
|