You are here

public function FileEntityDealerManager::createInstanceFromTypeAndScheme in Media Migration 8

Gets the plugin definitions for the specified file entity type.

Parameters

string $type: The file entity type.

string $scheme: The URI scheme.

Return value

\Drupal\media_migration\FileEntityDealerPluginInterface|null A fully configured plugin instance or NULL if no applicable plugin was found.

Overrides FileEntityDealerManagerInterface::createInstanceFromTypeAndScheme

File

src/FileEntityDealerManager.php, line 95

Class

FileEntityDealerManager
Manages discovery and instantiation of file entity dealer plugins.

Namespace

Drupal\media_migration

Code

public function createInstanceFromTypeAndScheme(string $type, string $scheme) {
  $filtered_definitions = $this
    ->getDefinitionsByTypeAndScheme($type, $scheme);
  if (!empty($filtered_definitions)) {
    try {
      $configuration = [
        'type' => $type,
        'scheme' => $scheme,
      ];
      $plugin_id = array_keys($filtered_definitions)[0];
      return $this
        ->createInstance($plugin_id, $configuration);
    } catch (PluginException $e) {
      return NULL;
    }
  }
  return NULL;
}