You are here

public static function ExternalHreflang::validateTag in External Hreflang 8

Validates the metatag data.

Parameters

array $element: The form element to process.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Overrides MetaNameBase::validateTag

File

src/Plugin/metatag/Tag/ExternalHreflang.php, line 89

Class

ExternalHreflang
A new hreflang tag will be made available for each language.

Namespace

Drupal\external_hreflang\Plugin\metatag\Tag

Code

public static function validateTag(array &$element, FormStateInterface $form_state) {
  $value = $form_state
    ->getValue($element['#parents']) ?? '';
  try {
    self::getHrefLangsArrayFromString($value);
  } catch (\Exception $e) {
    $form_state
      ->setError($element, t('Invalid value in @name', [
      '@name' => $element['#title'],
    ]));
  }
}