Commit 68717feb authored by Neslee Canil Pinto's avatar Neslee Canil Pinto Committed by Damien McKenna
Browse files

Issue #3124042 by Neslee Canil Pinto: t() calls should be avoided in classes,...

Issue #3124042 by Neslee Canil Pinto: t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead.
parent 018cb409
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx
  joshi.rohit100, baikho, valthebald: Drupal 9 compatibility fixes.
#3124039 by Grayle: Migration plugins alter does not check for presence of
  migration_tags.
#3124042 by Neslee Canil Pinto: t() calls should be avoided in classes, use
  \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead.


Metatag 8.x-1.12, 2020-03-30
+4 −1
Original line number Diff line number Diff line
@@ -5,12 +5,15 @@ namespace Drupal\metatag_hreflang\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * Create a new hreflang tag plugin for each enabled language.
 */
class HreflangDeriver extends DeriverBase {

  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
@@ -40,7 +43,7 @@ class HreflangDeriver extends DeriverBase {
      // The 'name' value is used as the value of the 'hreflang' attribute on
      // the HTML tag.
      $derivative['name'] = $langcode;
      $derivative['label'] = t("URL for a version of this page in %langcode", ['%langcode' => $language->getName()]);
      $derivative['label'] = $this->t("URL for a version of this page in %langcode", ['%langcode' => $language->getName()]);
      $derivative['description'] = '';

      // Reference derivatives based on their UUID instead of the record ID.
+11 −8
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\metatag_twitter_cards\Plugin\metatag\Tag;

use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * The Twitter Cards Type-tag.
@@ -21,6 +22,8 @@ use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase;
 */
class TwitterCardsType extends MetaNameBase {

  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
@@ -30,15 +33,15 @@ class TwitterCardsType extends MetaNameBase {
      '#title' => $this->label(),
      '#description' => $this->description(),
      '#options' => [
        'summary' => t('Summary Card'),
        'summary_large_image' => t('Summary Card with large image'),
        'photo' => t('Photo Card'),
        'gallery' => t('Gallery Card'),
        'app' => t('App Card'),
        'player' => t('Player Card'),
        'product' => t('Product Card'),
        'summary' => $this->t('Summary Card'),
        'summary_large_image' => $this->t('Summary Card with large image'),
        'photo' => $this->t('Photo Card'),
        'gallery' => $this->t('Gallery Card'),
        'app' => $this->t('App Card'),
        'player' => $this->t('Player Card'),
        'product' => $this->t('Product Card'),
      ],
      '#empty_option' => t('- None -'),
      '#empty_option' => $this->t('- None -'),
      '#empty_value' => '',
      '#default_value' => $this->value(),
      '#required' => isset($element['#required']) ? $element['#required'] : FALSE,
+4 −2
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use Drupal\metatag\MetatagToken;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\language\ConfigurableLanguageManagerInterface;
use Drupal\metatag_views\MetatagViewsValuesCleanerTrait;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * Class MetatagViewsEditForm.
@@ -20,6 +21,7 @@ use Drupal\metatag_views\MetatagViewsValuesCleanerTrait;
class MetatagViewsTranslationForm extends FormBase {

  use MetatagViewsValuesCleanerTrait;
  use StringTranslationTrait;

  /**
   * Drupal\metatag\MetatagManager definition.
@@ -177,12 +179,12 @@ class MetatagViewsTranslationForm extends FormBase {
    ]);

    $form['metatags'] = $this->form($form, $this->prepareValues());
    $form['metatags']['#title'] = t('Metatags');
    $form['metatags']['#title'] = $this->t('Metatags');
    $form['metatags']['#type'] = 'fieldset';

    $form['submit'] = [
      '#type' => 'submit',
      '#value' => t('Submit'),
      '#value' => $this->t('Submit'),
    ];

    return $form;
+7 −4
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Drupal\metatag_views\Plugin\views\display_extender;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * Metatag display extender plugin.
@@ -20,6 +21,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 */
class MetatagDisplayExtender extends DisplayExtenderPluginBase {

  use StringTranslationTrait;

  /**
   * The metatag manager.
   *
@@ -52,7 +55,7 @@ class MetatagDisplayExtender extends DisplayExtenderPluginBase {
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {

    if ($form_state->get('section') == 'metatags') {
      $form['#title'] .= t('The meta tags for this display');
      $form['#title'] .= $this->t('The meta tags for this display');
      $metatags = $this->getMetatags();

      // Build/inject the Metatag form.
@@ -106,13 +109,13 @@ class MetatagDisplayExtender extends DisplayExtenderPluginBase {
   */
  public function optionsSummary(&$categories, &$options) {
    $categories['metatags'] = [
      'title' => t('Meta tags'),
      'title' => $this->t('Meta tags'),
      'column' => 'second',
    ];
    $options['metatags'] = [
      'category' => 'metatags',
      'title' => t('Meta tags'),
      'value' => $this->hasMetatags() ? t('Overridden') : t('Using defaults'),
      'title' => $this->t('Meta tags'),
      'value' => $this->hasMetatags() ? $this->t('Overridden') : $this->t('Using defaults'),
    ];
  }

Loading