You are here

class SearchApiAlterCommentAccess in Search API 7

Adds node access information to comment indexes.

Hierarchy

Expanded class hierarchy of SearchApiAlterCommentAccess

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

File

includes/callback_comment_access.inc, line 10
Contains the SearchApiAlterCommentAccess class.

View source
class SearchApiAlterCommentAccess extends SearchApiAlterNodeAccess {

  /**
   * Overrides SearchApiAlterNodeAccess::supportsIndex().
   *
   * Returns TRUE only for indexes on comments.
   */
  public function supportsIndex(SearchApiIndex $index) {
    return $index
      ->getEntityType() === 'comment';
  }

  /**
   * Overrides SearchApiAlterNodeAccess::getNode().
   *
   * Returns the comment's node, instead of the item (i.e., the comment) itself.
   */
  protected function getNode($item) {
    return node_load($item->nid);
  }

  /**
   * Overrides SearchApiAlterNodeAccess::configurationFormSubmit().
   *
   * Doesn't index the comment's "Author".
   */
  public function configurationFormSubmit(array $form, array &$values, array &$form_state) {
    $old_status = !empty($form_state['index']->options['data_alter_callbacks']['search_api_alter_comment_access']['status']);
    $new_status = !empty($form_state['values']['callbacks']['search_api_alter_comment_access']['status']);
    if (!$old_status && $new_status) {
      $form_state['index']->options['fields']['status']['type'] = 'boolean';
    }
    return parent::configurationFormSubmit($form, $values, $form_state);
  }

}

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::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::__construct public function Implements SearchApiAlterCallbackInterface::__construct(). Overrides SearchApiAlterCallbackInterface::__construct 1
SearchApiAlterCommentAccess::configurationFormSubmit public function Overrides SearchApiAlterNodeAccess::configurationFormSubmit(). Overrides SearchApiAlterNodeAccess::configurationFormSubmit
SearchApiAlterCommentAccess::getNode protected function Overrides SearchApiAlterNodeAccess::getNode(). Overrides SearchApiAlterNodeAccess::getNode
SearchApiAlterCommentAccess::supportsIndex public function Overrides SearchApiAlterNodeAccess::supportsIndex(). Overrides SearchApiAlterNodeAccess::supportsIndex
SearchApiAlterNodeAccess::alterItems public function Alter items before indexing. Overrides SearchApiAlterCallbackInterface::alterItems
SearchApiAlterNodeAccess::propertyInfo public function Overrides SearchApiAbstractAlterCallback::propertyInfo(). Overrides SearchApiAbstractAlterCallback::propertyInfo