Commit 17019038 authored by Damien McKenna's avatar Damien McKenna Committed by Damien McKenna
Browse files

Issue #3302969 by DamienMcKenna: Refactored MetaNameBase output logic.

parent 0031240a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ Metatag 8.x-1.x-dev, 2022-xx-xx
#3303196 by DamienMcKenna: Add extra isSOMETHING() methods to MetaNameBase.
#3304779 by luigisa, DamienMcKenna: MetatagManager::processedTokenCache() does
  not respect the entity language.
#3302969 by DamienMcKenna: Refactored MetaNameBase output logic.


Metatag 8.x-1.21, 2022-07-16
+2 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\Tests\metatag_extended_perms\Functional;

use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\metatag\Functional\MetatagHelperTrait;

/**
 * Verify the new permissions are added.
@@ -12,7 +13,7 @@ use Drupal\Tests\BrowserTestBase;
class PermissionsTest extends BrowserTestBase {

  // Contains helper methods.
  use \Drupal\Tests\metatag\Functional\MetatagHelperTrait;
  use MetatagHelperTrait;

  /**
   * {@inheritdoc}
@@ -90,7 +91,6 @@ class PermissionsTest extends BrowserTestBase {

    // Create a content type with a Metatag field.
    $this->createContentType();
    $this->drupalGet('admin/people/permissions');
  }

  /**
+19 −9
Original line number Diff line number Diff line
@@ -32,15 +32,7 @@ class TwitterCardsType extends MetaNameBase {
      '#type' => 'select',
      '#title' => $this->label(),
      '#description' => $this->description(),
      '#options' => [
        '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'),
      ],
      '#options' => $this->formValues(),
      '#empty_option' => $this->t('- None -'),
      '#empty_value' => '',
      '#default_value' => $this->value(),
@@ -51,4 +43,22 @@ class TwitterCardsType extends MetaNameBase {
    return $form;
  }

  /**
   * The list of select values.
   *
   * @return array
   *   A list of values available for this select tag.
   */
  protected function formValues() {
    return [
      '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'),
    ];
  }

}
+17 −13
Original line number Diff line number Diff line
@@ -8,20 +8,24 @@ namespace Drupal\metatag\Plugin\metatag\Tag;
abstract class LinkRelBase extends MetaNameBase {

  /**
   * {@inheritdoc}
   * The string this tag uses for the tag itself.
   *
   * @var string
   */
  public function output() {
    $element = parent::output();
    if (!empty($element['#attributes']['content'])) {
      $element['#tag'] = 'link';
      $element['#attributes'] = [
        'rel' => $this->name(),
        'href' => $element['#attributes']['content'],
      ];
      unset($element['#attributes']['content']);
    }
  protected $htmlTag = 'link';

    return $element;
  }
  /**
   * The attribute this tag uses for the name.
   *
   * @var string
   */
  protected $htmlNameAttribute = 'rel';

  /**
   * The attribute this tag uses for the contents.
   *
   * @var string
   */
  protected $htmlValueAttribute = 'href';

}
+5 −0
Original line number Diff line number Diff line
@@ -14,4 +14,9 @@ abstract class MetaHttpEquivBase extends MetaNameBase {
   */
  protected $nameAttribute = 'http-equiv';

  /**
   * {@inheritdoc}
   */
  protected $htmlNameAttribute = 'http-equiv';

}
Loading