You are here

public static function FacetSourceDeriverBase::create in Facets 8

Creates a new class instance.

Parameters

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

string $base_plugin_id: The base plugin ID for the plugin ID.

Return value

static Returns an instance of this fetcher.

Overrides ContainerDeriverInterface::create

File

src/FacetSource/FacetSourceDeriverBase.php, line 42

Class

FacetSourceDeriverBase
A base class for facet source derivers.

Namespace

Drupal\facets\FacetSource

Code

public static function create(ContainerInterface $container, $base_plugin_id) {
  $deriver = new static();
  $module_list = $container
    ->get('module_handler')
    ->getModuleList();
  if (!in_array('search_api', array_keys($module_list))) {
    return;
  }
  $entity_type_manager = $container
    ->get('entity_type.manager');
  $deriver
    ->setEntityTypeManager($entity_type_manager);
  $translation = $container
    ->get('string_translation');
  $deriver
    ->setStringTranslation($translation);
  $search_api_display_plugin_manager = $container
    ->get('plugin.manager.search_api.display');
  $deriver
    ->setSearchApiDisplayPluginManager($search_api_display_plugin_manager);
  return $deriver;
}