You are here

public function SearchApiIndex::getAlterCallbacks in Search API 7

Loads all enabled data alterations for this index in proper order.

Return value

array All enabled callbacks for this index, as SearchApiAlterCallbackInterface objects.

2 calls to SearchApiIndex::getAlterCallbacks()
SearchApiIndex::dataAlter in includes/index_entity.inc
Calls data alteration hooks for a set of items, according to the index options.
SearchApiIndex::propertyInfoAlter in includes/index_entity.inc
Property info alter callback that adds the infos of the properties added by data alter callbacks.

File

includes/index_entity.inc, line 596
Contains SearchApiIndex.

Class

SearchApiIndex
Class representing a search index.

Code

public function getAlterCallbacks() {
  if (isset($this->callbacks)) {
    return $this->callbacks;
  }
  $this->callbacks = array();
  if (empty($this->options['data_alter_callbacks'])) {
    return $this->callbacks;
  }
  $callback_settings = $this->options['data_alter_callbacks'];
  $infos = search_api_get_alter_callbacks();
  foreach ($callback_settings as $id => $settings) {
    if (empty($settings['status'])) {
      continue;
    }
    if (empty($infos[$id]) || !class_exists($infos[$id]['class'])) {
      watchdog('search_api', t('Undefined data alteration @class specified in index @name', array(
        '@class' => $id,
        '@name' => $this->name,
      )), NULL, WATCHDOG_WARNING);
      continue;
    }
    $class = $infos[$id]['class'];
    $callback = new $class($this, empty($settings['settings']) ? array() : $settings['settings']);
    if (!$callback instanceof SearchApiAlterCallbackInterface) {
      watchdog('search_api', t('Unknown callback class @class specified for data alteration @name', array(
        '@class' => $class,
        '@name' => $id,
      )), NULL, WATCHDOG_WARNING);
      continue;
    }
    $this->callbacks[$id] = $callback;
  }
  return $this->callbacks;
}