You are here

abstract class SearchApiAbstractAlterCallback in Search API 7

Abstract base class for data-alter callbacks.

This class implements most methods with sensible defaults.

Extending classes will at least have to implement the alterItems() method to make this work. If that method adds additional fields to the items, propertyInfo() has to be overridden, too.

Hierarchy

Expanded class hierarchy of SearchApiAbstractAlterCallback

File

includes/callback.inc, line 125
Contains base definitions for data alterations.

View source
abstract class SearchApiAbstractAlterCallback implements SearchApiAlterCallbackInterface {

  /**
   * The index whose items will be altered.
   *
   * @var SearchApiIndex
   */
  protected $index;

  /**
   * The configuration options for this callback, if it has any.
   *
   * @var array
   */
  protected $options;

  /**
   * Implements SearchApiAlterCallbackInterface::__construct().
   */
  public function __construct(SearchApiIndex $index, array $options = array()) {
    $this->index = $index;
    $this->options = $options;
  }

  /**
   * Implements SearchApiAlterCallbackInterface::supportsIndex().
   *
   * The default implementation always returns TRUE.
   */
  public function supportsIndex(SearchApiIndex $index) {
    return TRUE;
  }

  /**
   * Implements SearchApiAlterCallbackInterface::configurationForm().
   */
  public function configurationForm() {
    return array();
  }

  /**
   * Implements SearchApiAlterCallbackInterface::configurationFormValidate().
   */
  public function configurationFormValidate(array $form, array &$values, array &$form_state) {
  }

  /**
   * Implements SearchApiAlterCallbackInterface::configurationFormSubmit().
   */
  public function configurationFormSubmit(array $form, array &$values, array &$form_state) {
    $this->options = $values;
    return $values;
  }

  /**
   * Implements SearchApiAlterCallbackInterface::propertyInfo().
   */
  public function propertyInfo() {
    return array();
  }

  /**
   * Determines whether the given index contains multiple types of entities.
   *
   * @param SearchApiIndex|null $index
   *   (optional) The index to examine. Defaults to the index set for this
   *   plugin.
   *
   * @return bool
   *   TRUE if the index is a multi-entity index, FALSE otherwise.
   */
  protected function isMultiEntityIndex(SearchApiIndex $index = NULL) {
    $index = $index ? $index : $this->index;
    return $index
      ->datasource() instanceof SearchApiCombinedEntityDataSourceController;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SearchApiAbstractAlterCallback::$index protected property The index whose items will be altered.
SearchApiAbstractAlterCallback::$options protected property The configuration options for this callback, if it has any.
SearchApiAbstractAlterCallback::configurationForm public function Implements SearchApiAlterCallbackInterface::configurationForm(). Overrides SearchApiAlterCallbackInterface::configurationForm 6
SearchApiAbstractAlterCallback::configurationFormSubmit public function Implements SearchApiAlterCallbackInterface::configurationFormSubmit(). Overrides SearchApiAlterCallbackInterface::configurationFormSubmit 4
SearchApiAbstractAlterCallback::configurationFormValidate public function Implements SearchApiAlterCallbackInterface::configurationFormValidate(). Overrides SearchApiAlterCallbackInterface::configurationFormValidate 1
SearchApiAbstractAlterCallback::isMultiEntityIndex protected function Determines whether the given index contains multiple types of entities.
SearchApiAbstractAlterCallback::propertyInfo public function Implements SearchApiAlterCallbackInterface::propertyInfo(). Overrides SearchApiAlterCallbackInterface::propertyInfo 6
SearchApiAbstractAlterCallback::supportsIndex public function Implements SearchApiAlterCallbackInterface::supportsIndex(). Overrides SearchApiAlterCallbackInterface::supportsIndex 10
SearchApiAbstractAlterCallback::__construct public function Implements SearchApiAlterCallbackInterface::__construct(). Overrides SearchApiAlterCallbackInterface::__construct 1
SearchApiAlterCallbackInterface::alterItems public function Alter items before indexing. 12