You are here

public static function SearchApiDisplay::create in Facets 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 FacetSourcePluginBase::create

File

src/Plugin/facets/facet_source/SearchApiDisplay.php, line 101

Class

SearchApiDisplay
Provides a facet source based on a Search API display.

Namespace

Drupal\facets\Plugin\facets\facet_source

Code

public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {

  // If the Search API module is not enabled, we should just return an empty
  // object. This allows us to have this class in the module without having a
  // dependency on the Search API module.
  if (!$container
    ->get('module_handler')
    ->moduleExists('search_api')) {
    return new \stdClass();
  }
  return new static($configuration, $plugin_id, $plugin_definition, $container
    ->get('plugin.manager.facets.query_type'), $container
    ->get('search_api.query_helper'), $container
    ->get('plugin.manager.search_api.display'), $container
    ->get('request_stack')
    ->getMasterRequest(), $container
    ->get('module_handler'));
}