Version 1
[yaffs-website] / web / modules / contrib / metatag / metatag_twitter_cards / src / Plugin / metatag / Tag / TwitterCardsType.php
1 <?php
2
3 namespace Drupal\metatag_twitter_cards\Plugin\metatag\Tag;
4
5 use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase;
6
7 /**
8  * The Twitter Cards Type-tag.
9  *
10  * @MetatagTag(
11  *   id = "twitter_cards_type",
12  *   label = @Translation("Twitter card type"),
13  *   description = @Translation("Notes: no other fields are required for a Summary card, a Photo card requires the 'image' field, a Media player card requires the 'title', 'description', 'media player URL', 'media player width', 'media player height' and 'image' fields, a Summary Card with Large Image card requires the 'Summary' field and the 'image' field, a Gallery Card requires all the 'Gallery Image' fields, an App Card requires the 'iPhone app ID' field, the 'iPad app ID' field and the 'Google Play app ID' field, a Product Card requires the 'description' field, the 'image' field, the 'Label 1' field, the 'Data 1' field, the 'Label 2' field and the 'Data 2' field."),
14  *   name = "twitter:card",
15  *   group = "twitter_cards",
16  *   weight = 1,
17  *   type = "string",
18  *   secure = FALSE,
19  *   multiple = FALSE
20  * )
21  */
22 class TwitterCardsType extends MetaNameBase {
23
24   /**
25    * {@inheritdoc}
26    */
27   public function form(array $element = []) {
28     $form = [
29       '#type' => 'select',
30       '#title' => $this->label(),
31       '#description' => $this->description(),
32       '#options' => [
33         'summary' => t('Summary Card'),
34         'summary_large_image' => t('Summary Card with large image'),
35         'photo' => t('Photo Card'),
36         'gallery' => t('Gallery Card'),
37         'app' => t('App Card'),
38         'player' => t('Player Card'),
39         'product' => t('Product Card'),
40       ],
41       '#empty_option' => t('- None -'),
42       '#empty_value' => '',
43       '#default_value' => $this->value(),
44       '#required' => isset($element['#required']) ? $element['#required'] : FALSE,
45       '#element_validate' => [[get_class($this), 'validateTag']],
46     ];
47
48     return $form;
49   }
50
51 }