You are here

class SkinrContextualLinks in Skinr 8.2

Provides dynamic contextual links to edit Skinr settings.

Hierarchy

Expanded class hierarchy of SkinrContextualLinks

See also

\Drupal\content_translation\Plugin\Menu\ContextualLink\ContentTranslationContextualLinks

File

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

Namespace

Drupal\skinr_ui\Plugin\Derivative
View source
class SkinrContextualLinks extends DeriverBase implements ContainerDeriverInterface {

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('plugin.manager.skinr_ui.mapper'));
  }

  /**
   * {@inheritdoc}
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
SkinrContextualLinks::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
SkinrContextualLinks::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions