You are here

public function ProviderManager::loadDefinitionsFromOptionList in Video Embed Field 8

Same name and namespace in other branches
  1. 8.2 src/ProviderManager.php \Drupal\video_embed_field\ProviderManager::loadDefinitionsFromOptionList()

Load the provider plugin definitions from a FAPI options list value.

Parameters

array $options: An array of options from a form API submission.

Return value

array An array of plugin definitions.

Overrides ProviderManagerInterface::loadDefinitionsFromOptionList

File

src/ProviderManager.php, line 37

Class

ProviderManager
Gathers the provider plugins.

Namespace

Drupal\video_embed_field

Code

public function loadDefinitionsFromOptionList($options) {
  $definitions = [];

  // When no options are selected, all plugins are applicable.
  if (count(array_keys($options, '0')) == count($options) || empty($options)) {
    return $this
      ->getDefinitions();
  }
  else {
    foreach ($options as $provider_id => $enabled) {
      if ($enabled) {
        $definitions[$provider_id] = $this
          ->getDefinition($provider_id);
      }
    }
  }
  return $definitions;
}