You are here

class SearchApiAlterNodeDomainAccess in Domain Integration (Drupal 7) 7

Same name and namespace in other branches
  1. 8 modules/domain_integration_search_api/includes/callback_node_domain_access.inc \SearchApiAlterNodeDomainAccess

Adds node domain access information to node indexes.

Hierarchy

Expanded class hierarchy of SearchApiAlterNodeDomainAccess

1 string reference to 'SearchApiAlterNodeDomainAccess'
domain_integration_search_api_search_api_alter_callback_info in modules/domain_integration_search_api/domain_integration_search_api.module
Implements hook_search_api_alter_callback_info().

File

modules/domain_integration_search_api/includes/callback_node_domain_access.inc, line 10
Contains the SearchApiAlterNodeDomainAccess class.

View source
class SearchApiAlterNodeDomainAccess extends SearchApiAbstractAlterCallback {

  /**
   * Overrides SearchApiAbstractAlterCallback::supportsIndex().
   *
   * This plugin only supports indexes containing nodes.
   */
  public function supportsIndex(SearchApiIndex $index) {

    // Currently only node access is supported.
    return $index
      ->getEntityType() === 'node';
  }

  /**
   * {@inheritdoc}
   */
  public function alterItems(array &$items) {
  }

  /**
   * Overrides SearchApiAbstractAlterCallback::configurationFormSubmit().
   *
   * If the data alteration is being enabled, set "Published" and "Author" to
   * "indexed", because both are needed for the node access filter.
   */
  public function configurationFormSubmit(array $form, array &$values, array &$form_state) {

    // Ensure the relevant domain properties are added to the index:
    //  - domain_domain_id (list of ID's the User has access to).
    //  - domain_domain_site (send-to-all property (everyone has access)).
    $old_status = !empty($form_state['index']->options['data_alter_callbacks']['search_api_alter_node_domain_access']['status']);
    $new_status = !empty($form_state['values']['callbacks']['search_api_alter_node_domain_access']['status']);
    if (!$old_status && $new_status) {
      $form_state['index']->options['fields']['domain_domain_site']['type'] = 'boolean';
      $form_state['index']->options['fields']['domain_domain_id']['type'] = 'integer';
    }
    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::propertyInfo public function Implements SearchApiAlterCallbackInterface::propertyInfo(). Overrides SearchApiAlterCallbackInterface::propertyInfo 6
SearchApiAbstractAlterCallback::__construct public function Implements SearchApiAlterCallbackInterface::__construct(). Overrides SearchApiAlterCallbackInterface::__construct 1
SearchApiAlterNodeDomainAccess::alterItems public function Alter items before indexing. Overrides SearchApiAlterCallbackInterface::alterItems
SearchApiAlterNodeDomainAccess::configurationFormSubmit public function Overrides SearchApiAbstractAlterCallback::configurationFormSubmit(). Overrides SearchApiAbstractAlterCallback::configurationFormSubmit
SearchApiAlterNodeDomainAccess::supportsIndex public function Overrides SearchApiAbstractAlterCallback::supportsIndex(). Overrides SearchApiAbstractAlterCallback::supportsIndex