You are here

public static function AdvancedHelpSearch::create in Advanced Help 8

Creates an instance of the plugin.

Parameters

\Symfony\Component\DependencyInjection\ContainerInterface $container: The container to pull out services used in the plugin.

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.

Return value

static Returns an instance of this plugin.

Overrides SearchPluginBase::create

File

src/Plugin/Search/AdvancedHelpSearch.php, line 64

Class

AdvancedHelpSearch
Executes a keyword search for Advanced Help against the {advanced_help} topic pages.

Namespace

Drupal\advanced_help\Plugin\Search

Code

public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
  $instance = new static($container
    ->get('database'), $container
    ->get('plugin.manager.advanced_help'), $container
    ->get('current_user'), $container
    ->get('config.factory')
    ->get('search.settings'), $configuration, $plugin_id, $plugin_definition);

  // The search Index service does not exist on Drupal 8.7 and below.
  if (floatval(\Drupal::VERSION) >= 8.800000000000001) {
    $instance->searchIndex = $container
      ->get('search.index');
  }
  return $instance;
}