You are here

public function EntityEmbedDisplayManager::getDefinitionOptionsForContext in Entity Embed 8

Gets definition options for context.

Provides a list of plugins that can be used for a certain context and filters out plugins that should be hidden in the UI.

Parameters

array $context: An array of context options; possible keys are 'entity', 'entity_type' and 'embed_button'.

Return value

string[] An array of valid plugin labels, keyed by plugin ID.

File

src/EntityEmbedDisplay/EntityEmbedDisplayManager.php, line 101

Class

EntityEmbedDisplayManager
Provides an Entity Embed display plugin manager.

Namespace

Drupal\entity_embed\EntityEmbedDisplay

Code

public function getDefinitionOptionsForContext(array $context) {
  $values = [
    'entity' => TRUE,
    'entity_type' => TRUE,
    'embed_button' => TRUE,
  ];
  assert(empty(array_diff_key($context, $values)));
  $definitions = $this
    ->getDefinitionsForContexts($context);
  $definitions = $this
    ->filterExposedDefinitions($definitions);
  $options = array_map(function ($definition) {
    return (string) $definition['label'];
  }, $definitions);
  natsort($options);
  return $options;
}