770124fe951b63810c7321acfc2654e4834697c1
[yaffs-website] / web / modules / contrib / metatag / src / Plugin / metatag / Tag / MetaPropertyBase.php
1 <?php
2
3 /**
4  * This base plugin allows "property"-style meta tags, e.g. Open Graph tags, to
5  * be further customized.
6  */
7
8 namespace Drupal\metatag\Plugin\metatag\Tag;
9
10 abstract class MetaPropertyBase extends MetaNameBase {
11   /**
12    * Display the meta tag.
13    */
14   public function output() {
15     if (empty($this->value)) {
16       // If there is no value, we don't want a tag output.
17       $element = '';
18     }
19     else {
20       // Parse out the image URL, if needed.
21       $value = $this->parseImageURL();
22
23       // If tag must be secure, convert all http:// to https://.
24       if ($this->secure() && strpos($value, 'http://') !== FALSE) {
25         $value = str_replace('http://', 'https://', $value);
26       }
27
28       $element = [
29         '#tag' => 'meta',
30         '#attributes' => [
31           'property' => $this->name,
32           'content' => $value,
33         ]
34       ];
35     }
36
37     return $element;
38   }
39 }