You are here

public function DataTypePluginManager::createInstance in Search API 8

Creates or retrieves a data type plugin.

Parameters

string $plugin_id: The ID of the plugin being instantiated.

array $configuration: (optional) An array of configuration relevant to the plugin instance. Ignored for data type plugins.

Return value

\Drupal\search_api\DataType\DataTypeInterface The requested data type plugin.

Throws

\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.

Overrides PluginManagerBase::createInstance

1 call to DataTypePluginManager::createInstance()
DataTypePluginManager::getInstances in src/DataType/DataTypePluginManager.php
Returns all known data types.

File

src/DataType/DataTypePluginManager.php, line 76

Class

DataTypePluginManager
Manages data type plugins.

Namespace

Drupal\search_api\DataType

Code

public function createInstance($plugin_id, array $configuration = []) {
  if (empty($this->dataTypes[$plugin_id])) {
    $this->dataTypes[$plugin_id] = parent::createInstance($plugin_id, $configuration);
  }
  return $this->dataTypes[$plugin_id];
}