ContentTranslationLocalTasks.php in Zircon Profile 8
File
core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php
View source
<?php
namespace Drupal\content_translation\Plugin\Derivative;
use Drupal\content_translation\ContentTranslationManagerInterface;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ContentTranslationLocalTasks extends DeriverBase implements ContainerDeriverInterface {
protected $basePluginId;
protected $contentTranslationManager;
public function __construct($base_plugin_id, ContentTranslationManagerInterface $content_translation_manager) {
$this->basePluginId = $base_plugin_id;
$this->contentTranslationManager = $content_translation_manager;
}
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('content_translation.manager'));
}
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->contentTranslationManager
->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
$translation_route_name = "entity.{$entity_type_id}.content_translation_overview";
$base_route_name = "entity.{$entity_type_id}.canonical";
$this->derivatives[$translation_route_name] = array(
'entity_type' => $entity_type_id,
'title' => 'Translate',
'route_name' => $translation_route_name,
'base_route' => $base_route_name,
) + $base_plugin_definition;
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}