class ConfigTranslationContextualLinks

Same name in other branches
  1. 8.9.x core/modules/config_translation/src/Plugin/Derivative/ConfigTranslationContextualLinks.php \Drupal\config_translation\Plugin\Derivative\ConfigTranslationContextualLinks
  2. 10 core/modules/config_translation/src/Plugin/Derivative/ConfigTranslationContextualLinks.php \Drupal\config_translation\Plugin\Derivative\ConfigTranslationContextualLinks
  3. 11.x core/modules/config_translation/src/Plugin/Derivative/ConfigTranslationContextualLinks.php \Drupal\config_translation\Plugin\Derivative\ConfigTranslationContextualLinks

Provides dynamic contextual links for configuration translation.

Hierarchy

Expanded class hierarchy of ConfigTranslationContextualLinks

1 string reference to 'ConfigTranslationContextualLinks'
config_translation.links.contextual.yml in core/modules/config_translation/config_translation.links.contextual.yml
core/modules/config_translation/config_translation.links.contextual.yml

File

core/modules/config_translation/src/Plugin/Derivative/ConfigTranslationContextualLinks.php, line 13

Namespace

Drupal\config_translation\Plugin\Derivative
View source
class ConfigTranslationContextualLinks extends DeriverBase implements ContainerDeriverInterface {
    
    /**
     * The mapper plugin discovery service.
     *
     * @var \Drupal\config_translation\ConfigMapperManagerInterface
     */
    protected $mapperManager;
    
    /**
     * Constructs a new ConfigTranslationContextualLinks.
     *
     * @param \Drupal\config_translation\ConfigMapperManagerInterface $mapper_manager
     *   The mapper plugin discovery service.
     */
    public function __construct(ConfigMapperManagerInterface $mapper_manager) {
        $this->mapperManager = $mapper_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, $base_plugin_id) {
        return new static($container->get('plugin.manager.config_translation.mapper'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDerivativeDefinitions($base_plugin_definition) {
        // Create contextual links for all mappers.
        $mappers = $this->mapperManager
            ->getMappers();
        foreach ($mappers as $plugin_id => $mapper) {
            // @todo Contextual groups do not map to entity types in a predictable
            //   way. See https://www.drupal.org/node/2134841 to make them
            //   predictable.
            $group_name = $mapper->getContextualLinkGroup();
            if (empty($group_name)) {
                continue;
            }
            
            /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
            $route_name = $mapper->getOverviewRouteName();
            $this->derivatives[$route_name] = $base_plugin_definition;
            $this->derivatives[$route_name]['config_translation_plugin_id'] = $plugin_id;
            $this->derivatives[$route_name]['class'] = '\\Drupal\\config_translation\\Plugin\\Menu\\ContextualLink\\ConfigTranslationContextualLink';
            $this->derivatives[$route_name]['route_name'] = $route_name;
            $this->derivatives[$route_name]['group'] = $group_name;
        }
        return parent::getDerivativeDefinitions($base_plugin_definition);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
ConfigTranslationContextualLinks::$mapperManager protected property The mapper plugin discovery service.
ConfigTranslationContextualLinks::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
ConfigTranslationContextualLinks::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
ConfigTranslationContextualLinks::__construct public function Constructs a new ConfigTranslationContextualLinks.
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.