abstract class FacetapiAdapter in Facet API 6
Same name and namespace in other branches
- 6.3 plugins/facetapi/adapter.inc \FacetapiAdapter
- 7.2 plugins/facetapi/adapter.inc \FacetapiAdapter
- 7 plugins/facetapi/adapter.inc \FacetapiAdapter
Abstract class extended by search backends that retrieves facet information from the database.
Hierarchy
- class \FacetapiAdapter
Expanded class hierarchy of FacetapiAdapter
1 string reference to 'FacetapiAdapter'
- facetapi_adapter_info_get in ./
facetapi.module - Invokes hook_facetapi_adapter_info(), returns all adapter definitions.
File
- ./
facetapi.adapter.inc, line 12 - Defines classes used by the FacetAPI module.
View source
abstract class FacetapiAdapter {
/**
* The machine readable name of the searcher module.
*/
protected $_searcher;
/**
* The type of content indexed by $this->_searcher.
*/
protected $_type;
/**
* The module that defines the adapter.
*/
protected $_module;
/**
* The search keys.
*/
protected $_keys;
/**
* An array of FacetapiFacet objects.
*/
protected $_facets = array();
/**
* Constructor, sets searcher and type of content being indexed.
*
* @param $searcher
* A string containing the machine readable name of the searcher module.
* @param $type
* A string containing the type of content indexed by $searcher.
* @param $module
* A string containing the module that defined the adapter.
*/
public function __construct($searcher, $type, $module) {
$this
->setSearcher($searcher)
->setType($type)
->setModule($module);
}
/**
* Returns a boolean flagging whether $this->_searcher executed a search.
*
* @return
* A boolean flagging whether $this->_searcher executed a search.
*
* @todo Generic search API should provide consistent functionality.
*/
public abstract function searchExecuted();
/**
* Returns a facet's active items.
*
* @param $facet
* An array containing the facet definition.
*
* @return
* An array containing the active items.
*/
public function getActiveItems(array $facet) {
return $this
->getFacet($facet)
->getActiveItems();
}
/**
* Returns an array of the facet's active item values.
*
* @param $facet
* An array containing the facet definition.
*
* @return
* An array containing the facet values keyed by position.
*/
public function getActiveValues(array $facet) {
return $this
->getFacet($facet)
->getActiveValues();
}
/**
* Tests whether a facet item is active by passing it's value.
*
* @param $facet
* An array containing the facet definition.
* @param $value
* A string containing the facet value.
*
* @return
* An integer, 1 if the facet is active, 0 if the facet is not active.
*/
public function itemActive($facet, $value) {
return $this
->getFacet($facet)
->itemActive($value);
}
/**
* Sets the searcher module.
*
* @param $searcher
* A string containing the machine readable name of the searcher module.
*
* @return
* An instance of this class.
*/
public function setSearcher($searcher) {
$this->_searcher = $searcher;
return $this;
}
/**
* Returns the searcher module.
*
* @return
* A string containing the machine readable name of the searcher module.
*/
public function getSearcher() {
return $this->_searcher;
}
/**
* Sets the type of content indexed by $this->_searcher.
*
* @param $type
* A string containing the type of content indexed by $this->_searcher.
*
* @return
* An instance of this class.
*/
public function setType($type) {
$this->_type = $type;
return $this;
}
/**
* Returns the type of content indexed by $this->_searcher.
*
* @return
* A string containing the type of content indexed by $this->_searcher.
*/
public function getType() {
return $this->_type;
}
/**
* Sets the module that defines the adapter.
*
* @param $module
* A string containing the module that defines the adapter.
* @return
* An instance of this class.
*/
public function setModule($module) {
$this->_module = $module;
return $this;
}
/**
* Returns the module that defines the adapter.
*
* @return
* A string containing the module that defines the adapter.
*/
public function getModule() {
return $this->_module;
}
/**
* Sets the search keys.
*/
public function setSearchKeys($keys) {
$this->_keys = $keys;
}
/**
* Gets the search keys.
*/
public function getSearchKeys() {
return $this->_keys;
}
/**
* Returns an instance of FacetapiFacet for a facet.
*
* @param $facet
* An array containing the facet definition.
*
* @return
* A FacetapiFacet object.
*/
public function getFacet(array $facet) {
if (!isset($this->_facets[$facet['name']])) {
$this->_facets[$facet['name']] = new FacetapiFacet($this, $facet);
}
return $this->_facets[$facet['name']];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FacetapiAdapter:: |
protected | property | An array of FacetapiFacet objects. | |
FacetapiAdapter:: |
protected | property | The search keys. | |
FacetapiAdapter:: |
protected | property | The module that defines the adapter. | |
FacetapiAdapter:: |
protected | property | The machine readable name of the searcher module. | |
FacetapiAdapter:: |
protected | property | The type of content indexed by $this->_searcher. | |
FacetapiAdapter:: |
public | function | Returns a facet's active items. | |
FacetapiAdapter:: |
public | function | Returns an array of the facet's active item values. | |
FacetapiAdapter:: |
public | function | Returns an instance of FacetapiFacet for a facet. | |
FacetapiAdapter:: |
public | function | Returns the module that defines the adapter. | |
FacetapiAdapter:: |
public | function | Returns the searcher module. | |
FacetapiAdapter:: |
public | function | Gets the search keys. | 2 |
FacetapiAdapter:: |
public | function | Returns the type of content indexed by $this->_searcher. | |
FacetapiAdapter:: |
public | function | Tests whether a facet item is active by passing it's value. | |
FacetapiAdapter:: |
abstract public | function | Returns a boolean flagging whether $this->_searcher executed a search. | 2 |
FacetapiAdapter:: |
public | function | Sets the module that defines the adapter. | |
FacetapiAdapter:: |
public | function | Sets the searcher module. | |
FacetapiAdapter:: |
public | function | Sets the search keys. | |
FacetapiAdapter:: |
public | function | Sets the type of content indexed by $this->_searcher. | |
FacetapiAdapter:: |
public | function | Constructor, sets searcher and type of content being indexed. |