elasticsearch_search_api-1.0.x-dev/elasticsearch_search_api.module

elasticsearch_search_api.module
<?php

/**
 * @file
 * Contains elasticsearch_search_api.module.
 */

use Drupal\Core\Cache\Cache;
use Drupal\node\NodeTypeInterface;
use Drupal\elasticsearch_search_api\Utility\UtilityHelper;

/**
 * Implements hook_help().
 */
function elasticsearch_search_api_help($route_name) {
  switch ($route_name) {
    // Main module help for the elasticsearch_search_api module.
    case 'help.page.elasticsearch_search_api':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('elasticsearch_search_api search functionality') . '</p>';
      return $output;

    default:
  }
}

/**
 * Implements hook_theme().
 */
function elasticsearch_search_api_theme() {
  return [
    'elasticsearch_search_api_search' => [
      'variables' => [
        'header' => NULL,
        'facets' => [],
        'active_filters' => NULL,
        'results' => [],
        'result_count' => NULL,
        'breadcrumbs' => NULL,
        'did_you_mean' => NULL,
      ],
    ],
    'elasticsearch_search_api_error' => [
      'variables' => [
        'error_message' => NULL,
      ],
    ],
    'elasticsearch_search_api_facets_item_list' => [
      'variables' => [
        'items' => [],
        'title' => '',
        'list_type' => 'ul',
        'wrapper_attributes' => [],
        'attributes' => [],
        'empty' => NULL,
        'context' => [],
      ],
    ],
    'elasticsearch_search_api_autocomplete' => [
      'variables' => [
        'results' => [],
        'layout_wide' => TRUE,
      ],
    ],
    'elasticsearch_search_api_result_count' => [
      'variables' => [
        'result_count' => '',
      ],
    ],
    'elasticsearch_search_api_facets_result_item' => [
      'variables' => [
        'value' => '',
        'show_count' => FALSE,
        'count' => NULL,
        'is_active' => FALSE,
        'for' => '',
        'has_children' => FALSE,
        'children' => NULL,
      ],
    ],
    'elasticsearch_search_api_facets' => [
      'variables' => [
        'facets' => [],
      ],
    ],
    'elasticsearch_search_api_suggestions' => [
      'variables' => [
        'did_you_mean_label' => NULL,
        'suggestions' => [],
      ],
    ],
  ];
}

/**
 * Prepares variables for facets item list templates.
 *
 * Default template: elasticsearch-search-api-facets-item-list.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - items: An array of items to be displayed in the list. Each item can be
 *     either a string or a render array. If #type, #theme, or #markup
 *     properties are not specified for child render arrays, they will be
 *     inherited from the parent list, allowing callers to specify larger
 *     nested lists without having to explicitly specify and repeat the
 *     render properties for all nested child lists.
 *   - title: A title to be prepended to the list.
 *   - list_type: The type of list to return (e.g. "ul", "ol").
 *   - wrapper_attributes: HTML attributes to be applied to the list wrapper.
 *
 * @see https://www.drupal.org/node/1842756
 */
function elasticsearch_search_api_preprocess_elasticsearch_search_api_facets_item_list(array &$variables) {
  template_preprocess_item_list($variables);
}

/**
 * Implements hook_cron().
 */
function elasticsearch_search_api_cron() {
  /** @var \Drupal\elasticsearch_search_api\SyncService $syncService */
  $syncService = \Drupal::service('elasticsearch_search_api.sync');
  $syncService->sync();
}

/**
 * Implements hook_search_api_items_indexed().
 */
function elasticsearch_search_api_api_items_indexed() {
  Cache::invalidateTags(['elasticsearch_search_api.search']);
}

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function elasticsearch_search_api_node_type_insert(NodeTypeInterface $node_type) {
  UtilityHelper::configureSearchIndexViewMode($node_type);
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc