You are here

public function SkinrContextualLinks::getDerivativeDefinitions in Skinr 8.2

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

skinr_ui/src/Plugin/Derivative/SkinrContextualLinks.php, line 33
Contains \Drupal\skinr_ui\Plugin\Derivative\SkinrContextualLinks.

Class

SkinrContextualLinks
Provides dynamic contextual links to edit Skinr settings.

Namespace

Drupal\skinr_ui\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {

  // @todo Get this to work somehow.
  foreach (array(
    'block',
    'node',
    'view',
  ) as $entity_type_id) {
    $route_name = 'skinr_ui.edit.' . $entity_type_id;
    $this->derivatives[$route_name] = $base_plugin_definition;
    $this->derivatives[$route_name]['route_name'] = 'entity.skin.edit.' . $entity_type_id;
    $this->derivatives[$route_name]['route_parameters'] = array(
      'element_type' => $entity_type_id,
      'element' => 'placeholder',
    );

    // @todo Contextual groups do not map to entity types in a predictable
    //   way. See https://drupal.org/node/2134841 to make them predictable.
    $this->derivatives[$route_name]['group'] = $entity_type_id;
  }
  return parent::getDerivativeDefinitions($base_plugin_definition);
}