Commit fa1a8483 authored by Jur de Vries's avatar Jur de Vries

Fixed sort plugin structure.

parent ed441011
...@@ -20,7 +20,7 @@ use Drupal\facetapi\Plugin\AdapterInterface; ...@@ -20,7 +20,7 @@ use Drupal\facetapi\Plugin\AdapterInterface;
* enabled facets or passing the appropriate query type plugin to the backend * enabled facets or passing the appropriate query type plugin to the backend
* so that it can execute the actual facet query. * so that it can execute the actual facet query.
*/ */
class AdapterBase implements AdapterInterface { abstract class AdapterBase implements AdapterInterface {
/** /**
* The searcher information as returned by facetapi_get_searcher_info(). * The searcher information as returned by facetapi_get_searcher_info().
...@@ -64,26 +64,6 @@ class AdapterBase implements AdapterInterface { ...@@ -64,26 +64,6 @@ class AdapterBase implements AdapterInterface {
*/ */
protected $queryTypes = array(); protected $queryTypes = array();
/**
* Returns a boolean flagging whether facets in a realm shoud be displayed.
*
* Useful, for example, for suppressing sidebar blocks in some cases. Apache
* Solr Search Integration used this method to prevent blocks from being
* displayed when the module was configured to render them in the search body
* on "empty" searches instead of the normal facet location.
*
* @param string $realm_name
* The machine readable name of the realm.
*
* @return boolean
* A boolean flagging whether to display a given realm.
*
* @todo It appears that no implementing modules are leveraging this anymore.
* Let's discuss whether to deprecate this method or even remove it from
* future versions of Facet API at http://drupal.org/node/1661410.
*/
public function suppressOutput($realm_name);
/** /**
* @TODO: generalize to ProcessorInterface and properly type hint in __construct(). * @TODO: generalize to ProcessorInterface and properly type hint in __construct().
* The url processor plugin associated with this adapter. * The url processor plugin associated with this adapter.
...@@ -167,17 +147,6 @@ class AdapterBase implements AdapterInterface { ...@@ -167,17 +147,6 @@ class AdapterBase implements AdapterInterface {
$this->initUrlProcessor(); $this->initUrlProcessor();
} }
/**
* Returns a boolean flagging whether $this->searcher['searcher'] executed a
* search.
*
* @return boolean
* A boolean flagging whether $this->searcher['searcher'] executed a search.
*
* @todo Generic search API should provide consistent functionality.
*/
public function searchExecuted();
/** /**
* Returns a boolean flagging whether $this->searcher['searcher'] executed a * Returns a boolean flagging whether $this->searcher['searcher'] executed a
* search. * search.
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
namespace Drupal\facetapi\Plugin\FacetApi\Sort; namespace Drupal\facetapi\Plugin\FacetApi\Sort;
use Drupal\Core\Annotation\Translation; use Drupal\facetapi\Sort\SortPluginBase;
use Drupal\facetapi\Annotation\FacetApiSort;
use Drupal\facetapi\Sort\FacetApiSortBase;
/** /**
* @FacetApiSort( * @FacetApiSort(
...@@ -13,7 +11,7 @@ use Drupal\facetapi\Sort\FacetApiSortBase; ...@@ -13,7 +11,7 @@ use Drupal\facetapi\Sort\FacetApiSortBase;
* description = @Translation("Sort by whether the facet is active or not.") * description = @Translation("Sort by whether the facet is active or not.")
* ) * )
*/ */
class SortActive extends FacetApiSortBase { class SortActive extends SortPluginBase {
public function sort(array $a, array $b) { public function sort(array $a, array $b) {
$a_active = (isset($a['#active'])) ? $a['#active'] : 0; $a_active = (isset($a['#active'])) ? $a['#active'] : 0;
$b_active = (isset($b['#active'])) ? $b['#active'] : 0; $b_active = (isset($b['#active'])) ? $b['#active'] : 0;
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
namespace Drupal\facetapi\Plugin\FacetApi\Sort; namespace Drupal\facetapi\Plugin\FacetApi\Sort;
use Drupal\Core\Annotation\Translation; use Drupal\facetapi\Sort\SortPluginBase;
use Drupal\facetapi\Annotation\FacetApiSort;
use Drupal\facetapi\Sort\FacetApiSortBase;
/** /**
* @FacetApiSort( * @FacetApiSort(
...@@ -13,7 +11,7 @@ use Drupal\facetapi\Sort\FacetApiSortBase; ...@@ -13,7 +11,7 @@ use Drupal\facetapi\Sort\FacetApiSortBase;
* description = @Translation("Sort by the facet count.") * description = @Translation("Sort by the facet count.")
* ) * )
*/ */
class SortCount extends FacetApiSortBase { class SortCount extends SortPluginBase {
public function sort(array $a, array $b) { public function sort(array $a, array $b) {
$a_count = (isset($a['#count'])) ? $a['#count'] : 0; $a_count = (isset($a['#count'])) ? $a['#count'] : 0;
$b_count = (isset($b['#count'])) ? $b['#count'] : 0; $b_count = (isset($b['#count'])) ? $b['#count'] : 0;
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
namespace Drupal\facetapi\Plugin\FacetApi\Sort; namespace Drupal\facetapi\Plugin\FacetApi\Sort;
use Drupal\Core\Annotation\Translation; use Drupal\facetapi\Sort\SortPluginBase;
use Drupal\facetapi\Annotation\FacetApiSort;
use Drupal\facetapi\Sort\FacetApiSortBase;
/** /**
* @FacetApiSort( * @FacetApiSort(
...@@ -13,7 +11,7 @@ use Drupal\facetapi\Sort\FacetApiSortBase; ...@@ -13,7 +11,7 @@ use Drupal\facetapi\Sort\FacetApiSortBase;
* description = @Translation("Sort by the value displayed to the user.") * description = @Translation("Sort by the value displayed to the user.")
* ) * )
*/ */
class SortDisplay extends FacetApiSortBase { class SortDisplay extends SortPluginBase {
public function sort(array $a, array $b) { public function sort(array $a, array $b) {
return strcasecmp($a['#markup'], $b['#markup']); return strcasecmp($a['#markup'], $b['#markup']);
} }
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
namespace Drupal\facetapi\Plugin\FacetApi\Sort; namespace Drupal\facetapi\Plugin\FacetApi\Sort;
use Drupal\Core\Annotation\Translation; use Drupal\facetapi\Sort\SortPluginBase;
use Drupal\facetapi\Annotation\FacetApiSort;
use Drupal\facetapi\Sort\FacetApiSortBase;
/** /**
* @FacetApiSort( * @FacetApiSort(
...@@ -13,7 +12,7 @@ use Drupal\facetapi\Sort\FacetApiSortBase; ...@@ -13,7 +12,7 @@ use Drupal\facetapi\Sort\FacetApiSortBase;
* description = @Translation("Sort by the raw value stored in the index.") * description = @Translation("Sort by the raw value stored in the index.")
* ) * )
*/ */
class SortIndexed extends FacetApiSortBase { class SortIndexed extends SortPluginBase {
public function sort(array $a, array $b) { public function sort(array $a, array $b) {
$a_value = (isset($a['#indexed_value'])) ? $a['#indexed_value'] : ''; $a_value = (isset($a['#indexed_value'])) ? $a['#indexed_value'] : '';
$b_value = (isset($b['#indexed_value'])) ? $b['#indexed_value'] : ''; $b_value = (isset($b['#indexed_value'])) ? $b['#indexed_value'] : '';
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
namespace Drupal\facetapi\Sort; namespace Drupal\facetapi\Sort;
use Drupal\Component\Plugin\PluginBase; use Drupal\Component\Plugin\PluginBase;
use Drupal\facetapi\Sort\SortInterface;
class SortPluginBase extends PluginBase implements FacetApiSortInterface { class SortPluginBase extends PluginBase implements SortInterface {
private $weight; private $weight;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment