"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php" (26 Nov 2020, 1474 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ConfigTranslationLocalTask.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\config_translation\Plugin\Menu\LocalTask;
    4 
    5 use Drupal\Core\Menu\LocalTaskDefault;
    6 use Drupal\Core\StringTranslation\StringTranslationTrait;
    7 use Symfony\Component\HttpFoundation\Request;
    8 
    9 /**
   10  * Defines a local task plugin with a dynamic title.
   11  */
   12 class ConfigTranslationLocalTask extends LocalTaskDefault {
   13   use StringTranslationTrait;
   14 
   15   /**
   16    * The mapper plugin discovery service.
   17    *
   18    * @var \Drupal\config_translation\ConfigMapperManagerInterface
   19    */
   20   protected $mapperManager;
   21 
   22   /**
   23    * {@inheritdoc}
   24    */
   25   public function getTitle(Request $request = NULL) {
   26     // Take custom 'config_translation_plugin_id' plugin definition key to
   27     // retrieve title. We need to retrieve a runtime title (as opposed to
   28     // storing the title on the plugin definition for the link) because
   29     // it contains translated parts that we need in the runtime language.
   30     $type_name = mb_strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
   31     return $this->t('Translate @type_name', ['@type_name' => $type_name]);
   32   }
   33 
   34   /**
   35    * Gets the mapper manager.
   36    *
   37    * @return \Drupal\config_translation\ConfigMapperManagerInterface
   38    *   The mapper manager.
   39    */
   40   protected function mapperManager() {
   41     if (!$this->mapperManager) {
   42       $this->mapperManager = \Drupal::service('plugin.manager.config_translation.mapper');
   43     }
   44     return $this->mapperManager;
   45   }
   46 
   47 }