You are here

class ContentTranslationContextualLinks in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php \Drupal\content_translation\Plugin\Derivative\ContentTranslationContextualLinks
  2. 10 core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php \Drupal\content_translation\Plugin\Derivative\ContentTranslationContextualLinks

Provides dynamic contextual links for content translation.

Hierarchy

Expanded class hierarchy of ContentTranslationContextualLinks

See also

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

1 string reference to 'ContentTranslationContextualLinks'
content_translation.links.contextual.yml in core/modules/content_translation/content_translation.links.contextual.yml
core/modules/content_translation/content_translation.links.contextual.yml

File

core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php, line 15

Namespace

Drupal\content_translation\Plugin\Derivative
View source
class ContentTranslationContextualLinks extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The content translation manager.
   *
   * @var \Drupal\content_translation\ContentTranslationManagerInterface
   */
  protected $contentTranslationManager;

  /**
   * Constructs a new ContentTranslationContextualLinks.
   *
   * @param \Drupal\content_translation\ContentTranslationManagerInterface $content_translation_manager
   *   The content translation manager.
   */
  public function __construct(ContentTranslationManagerInterface $content_translation_manager) {
    $this->contentTranslationManager = $content_translation_manager;
  }

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

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {

    // Create contextual links for translatable entity types.
    foreach ($this->contentTranslationManager
      ->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
      $this->derivatives[$entity_type_id]['title'] = t('Translate');
      $this->derivatives[$entity_type_id]['route_name'] = "entity.{$entity_type_id}.content_translation_overview";
      $this->derivatives[$entity_type_id]['group'] = $entity_type_id;
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
  }

}

Members

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