You are here

public function DataGeneratorPluginManager::getDefinitionsByDataType in YAML Content 8.2

Load plugin definitions supporting a data type.

Parameters

string $data_type: The supported data type being searched for.

Return value

mixed[] An associative array of plugin definitions keyed by the plugin ID. Only plugins supporting the requested data type are returned, and an empty array is returned if no matching plugin definitions were found.

File

modules/sample_data/src/DataGeneratorPluginManager.php, line 42

Class

DataGeneratorPluginManager
Plugin manager service for data generator plugins.

Namespace

Drupal\sample_data

Code

public function getDefinitionsByDataType($data_type) {
  $all_plugins = $this
    ->getDefinitions();
  $matches = [];
  if ($all_plugins) {
    foreach ($all_plugins as $id => $definition) {
      if (isset($definition->data_type) && $definition->data_type == $data_type) {
        $matches[$id] = $definition;
      }
    }
  }
  return $matches;
}