You are here

public function ViewModeDeriver::getDerivativeDefinitions in Entity Embed 8

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Derivative/ViewModeDeriver.php, line 58

Class

ViewModeDeriver
Provides Entity Embed Display plugin definitions for view modes.

Namespace

Drupal\entity_embed\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $no_ui = $this->configFactory
    ->get('entity_embed.settings')
    ->get('rendered_entity_mode');
  foreach ($this->entityDisplayRepository
    ->getAllViewModes() as $view_modes) {
    foreach ($view_modes as $view_mode => $definition) {
      $this->derivatives[$definition['id']] = [
        'label' => $definition['label'],
        'view_mode' => $view_mode,
        'entity_types' => [
          $definition['targetEntityType'],
        ],
        'no_ui' => $no_ui,
        // Check if the plugin should run through MediaImageDecorator. A more
        // fine-grained access check happens there.
        'supports_image_alt_and_title' => $definition['targetEntityType'] === 'media',
      ] + $base_plugin_definition;
    }
  }
  return $this->derivatives;
}