metatag-8.x-1.x-dev/metatag_pinterest/src/Plugin/metatag/Tag/PinterestNohover.php
metatag_pinterest/src/Plugin/metatag/Tag/PinterestNohover.php
<?php
namespace Drupal\metatag_pinterest\Plugin\metatag\Tag;
use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase;
/**
* The Pinterest "nohover" meta tag.
*
* @MetatagTag(
* id = "pinterest_nohover",
* label = @Translation("No hover"),
* description = @Translation("Do not show hovering Save or Search buttons, generated by the Pinterest browser extensions."),
* name = "pinterest",
* group = "pinterest",
* weight = 2,
* type = "string",
* secure = FALSE,
* multiple = FALSE
* )
*/
class PinterestNohover extends MetaNameBase {
/**
* {@inheritdoc}
*/
public function form(array $element = []): array {
$form = [
'#type' => 'checkbox',
'#title' => $this->label(),
'#description' => $this->description(),
'#default_value' => ($this->value === 'nohover') ?: '',
'#required' => $element['#required'] ?? FALSE,
'#element_validate' => [[get_class($this), 'validateTag']],
'#return_value' => 'nohover',
];
return $form;
}
/**
* {@inheritdoc}
*/
public function getTestFormXpath(): array {
return ["//input[@name='{$this->id}' and @type='checkbox']"];
}
/**
* {@inheritdoc}
*/
public function getTestOutputExistsXpath(): array {
return ["//" . $this->htmlTag . "[@" . $this->htmlNameAttribute . "='{$this->name}' and @content='nohover']"];
}
/**
* {@inheritdoc}
*/
public function getTestOutputValuesXpath(array $values): array {
return ["//" . $this->htmlTag . "[@" . $this->htmlNameAttribute . "='{$this->name}' and @content='nohover']"];
}
}
