You are here

public function NodeSearch::__construct in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/node/src/Plugin/Search/NodeSearch.php \Drupal\node\Plugin\Search\NodeSearch::__construct()
  2. 10 core/modules/node/src/Plugin/Search/NodeSearch.php \Drupal\node\Plugin\Search\NodeSearch::__construct()

Constructs a \Drupal\node\Plugin\Search\NodeSearch object.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin_id for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

\Drupal\Core\Database\Connection $database: The current database connection.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: A module manager object.

\Drupal\Core\Config\Config $search_settings: A config object for 'search.settings'.

\Drupal\Core\Language\LanguageManagerInterface $language_manager: The language manager.

\Drupal\Core\Render\RendererInterface $renderer: The renderer.

\Drupal\Core\Messenger\MessengerInterface $messenger: The messenger.

\Drupal\Core\Session\AccountInterface $account: The $account object to use for checking for access to advanced search.

\Drupal\Core\Database\Connection|null $database_replica: (Optional) the replica database connection.

\Drupal\search\SearchIndexInterface $search_index: The search index.

Overrides ConfigurableSearchPluginBase::__construct

File

core/modules/node/src/Plugin/Search/NodeSearch.php, line 199

Class

NodeSearch
Handles searching for node entities using the Search module index.

Namespace

Drupal\node\Plugin\Search

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, Config $search_settings, LanguageManagerInterface $language_manager, RendererInterface $renderer, MessengerInterface $messenger, AccountInterface $account = NULL, Connection $database_replica = NULL, SearchIndexInterface $search_index = NULL) {
  $this->database = $database;
  $this->databaseReplica = $database_replica ?: $database;
  $this->entityTypeManager = $entity_type_manager;
  $this->moduleHandler = $module_handler;
  $this->searchSettings = $search_settings;
  $this->languageManager = $language_manager;
  $this->renderer = $renderer;
  $this->messenger = $messenger;
  $this->account = $account;
  parent::__construct($configuration, $plugin_id, $plugin_definition);
  $this
    ->addCacheTags([
    'node_list',
  ]);
  if (!$search_index) {
    @trigger_error('Calling NodeSearch::__construct() without the $search_index argument is deprecated in drupal:8.8.0 and is required in drupal:9.0.0. See https://www.drupal.org/node/3075696', E_USER_DEPRECATED);
    $search_index = \Drupal::service('search.index');
  }
  $this->searchIndex = $search_index;
}