You are here

class SearchApiAlterUserStatus in Search API 7

Filters out blocked user accounts.

Hierarchy

Expanded class hierarchy of SearchApiAlterUserStatus

1 string reference to 'SearchApiAlterUserStatus'
search_api_search_api_alter_callback_info in ./search_api.module
Implements hook_search_api_alter_callback_info().

File

includes/callback_user_status.inc, line 11
Contains the SearchApiAlterUserStatus class.

View source
class SearchApiAlterUserStatus extends SearchApiAbstractAlterCallback {

  /**
   * {@inheritdoc}
   */
  public function supportsIndex(SearchApiIndex $index) {
    if ($this
      ->isMultiEntityIndex($index)) {
      return in_array('user', $index->options['datasource']['types']);
    }
    return $index
      ->getEntityType() == 'user';
  }

  /**
   * {@inheritdoc}
   */
  public function alterItems(array &$items) {
    $multi_types = $this
      ->isMultiEntityIndex($this->index);
    foreach ($items as $id => $item) {
      $account = $item;
      if ($multi_types) {
        if ($item->item_type !== 'user') {
          continue;
        }
        $account = $item->user;
      }
      if (empty($account->status)) {
        unset($items[$id]);
      }
    }
  }

}

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::__construct public function Implements SearchApiAlterCallbackInterface::__construct(). Overrides SearchApiAlterCallbackInterface::__construct 1
SearchApiAlterUserStatus::alterItems public function Alter items before indexing. Overrides SearchApiAlterCallbackInterface::alterItems
SearchApiAlterUserStatus::supportsIndex public function Implements SearchApiAlterCallbackInterface::supportsIndex(). Overrides SearchApiAbstractAlterCallback::supportsIndex