Backup of db before drupal security update
[yaffs-website] / web / core / modules / content_translation / src / Plugin / Derivative / ContentTranslationContextualLinks.php
1 <?php
2
3 namespace Drupal\content_translation\Plugin\Derivative;
4
5 use Drupal\Component\Plugin\Derivative\DeriverBase;
6 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
7 use Drupal\content_translation\ContentTranslationManagerInterface;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
9
10 /**
11  * Provides dynamic contextual links for content translation.
12  *
13  * @see \Drupal\content_translation\Plugin\Menu\ContextualLink\ContentTranslationContextualLinks
14  */
15 class ContentTranslationContextualLinks extends DeriverBase implements ContainerDeriverInterface {
16
17   /**
18    * The content translation manager.
19    *
20    * @var \Drupal\content_translation\ContentTranslationManagerInterface
21    */
22   protected $contentTranslationManager;
23
24   /**
25    * Constructs a new ContentTranslationContextualLinks.
26    *
27    * @param \Drupal\content_translation\ContentTranslationManagerInterface $content_translation_manager
28    *   The content translation manager.
29    */
30   public function __construct(ContentTranslationManagerInterface $content_translation_manager) {
31     $this->contentTranslationManager = $content_translation_manager;
32   }
33
34   /**
35    * {@inheritdoc}
36    */
37   public static function create(ContainerInterface $container, $base_plugin_id) {
38     return new static(
39       $container->get('content_translation.manager')
40     );
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function getDerivativeDefinitions($base_plugin_definition) {
47     // Create contextual links for translatable entity types.
48     foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
49       $this->derivatives[$entity_type_id]['title'] = t('Translate');
50       $this->derivatives[$entity_type_id]['route_name'] = "entity.$entity_type_id.content_translation_overview";
51       $this->derivatives[$entity_type_id]['group'] = $entity_type_id;
52     }
53     return parent::getDerivativeDefinitions($base_plugin_definition);
54   }
55
56 }