You are here

public static function ContentEntity::create in Search API 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 ConfigurablePluginBase::create

File

src/Plugin/search_api/datasource/ContentEntity.php, line 158

Class

ContentEntity
Represents a datasource which exposes the content entities.

Namespace

Drupal\search_api\Plugin\search_api\datasource

Code

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

  /** @var static $datasource */
  $datasource = parent::create($container, $configuration, $plugin_id, $plugin_definition);
  $datasource
    ->setDatabaseConnection($container
    ->get('database'));
  $datasource
    ->setEntityTypeManager($container
    ->get('entity_type.manager'));
  $datasource
    ->setEntityFieldManager($container
    ->get('entity_field.manager'));
  $datasource
    ->setEntityDisplayRepository($container
    ->get('entity_display.repository'));
  $datasource
    ->setEntityTypeBundleInfo($container
    ->get('entity_type.bundle.info'));
  $datasource
    ->setTypedDataManager($container
    ->get('typed_data_manager'));
  $datasource
    ->setConfigFactory($container
    ->get('config.factory'));
  $datasource
    ->setLanguageManager($container
    ->get('language_manager'));
  $datasource
    ->setFieldsHelper($container
    ->get('search_api.fields_helper'));
  $datasource
    ->setState($container
    ->get('state'));
  $datasource
    ->setEntityMemoryCache($container
    ->get('entity.memory_cache'));
  $datasource
    ->setLogger($container
    ->get('logger.channel.search_api'));
  return $datasource;
}