ConfigTranslationContextualLinks.php in Drupal 10
File
core/modules/config_translation/src/Plugin/Derivative/ConfigTranslationContextualLinks.php
View source
<?php
namespace Drupal\config_translation\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\config_translation\ConfigMapperManagerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ConfigTranslationContextualLinks extends DeriverBase implements ContainerDeriverInterface {
protected $mapperManager;
public function __construct(ConfigMapperManagerInterface $mapper_manager) {
$this->mapperManager = $mapper_manager;
}
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('plugin.manager.config_translation.mapper'));
}
public function getDerivativeDefinitions($base_plugin_definition) {
$mappers = $this->mapperManager
->getMappers();
foreach ($mappers as $plugin_id => $mapper) {
$group_name = $mapper
->getContextualLinkGroup();
if (empty($group_name)) {
continue;
}
$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);
}
}