You are here

public function DrupalMaskIconMetaTag::getElement in Metatag 7

Get the HTML tag for this meta tag.

Return value

array A render array for this meta tag.

Overrides DrupalDefaultMetaTag::getElement

File

metatag_favicons/metatag_favicons.mask-icon.class.inc, line 63
Custom class for the mask-icon meta tag's custom data.

Class

DrupalMaskIconMetaTag
Mask icon meta tag controller.

Code

public function getElement(array $options = array()) {
  $value = $this
    ->getValue($options);

  // This meta tag has two separate values.
  $color = $value['color'];
  $value = $value['value'];

  // Don't bother proceeding if the 'value' is empty.
  if (strlen($value) === 0) {
    return array();
  }

  // The stack of elements that will be output.
  $elements = array();

  // Dynamically add each option to this setting.
  $base_element = isset($this->info['element']) ? $this->info['element'] : array();

  // Combine the base configuration for this meta tag with the value.
  $element = $base_element + array(
    '#theme' => 'metatag',
    '#tag' => 'link',
    '#id' => 'metatag_' . $this->info['name'] . '_' . 1,
    '#rel' => $this->info['name'],
    '#name' => $this->info['name'],
    '#value' => $value,
    '#color' => $color,
    '#weight' => $this
      ->getWeight(),
  );

  // Add header information if desired.
  if (!empty($this->info['header'])) {
    $element['#attached']['drupal_add_http_header'][] = array(
      $this->info['header'],
      $value,
    );
  }
  $elements[] = array(
    $element,
    $element['#id'],
  );
  return array(
    '#attached' => array(
      'drupal_add_html_head' => $elements,
    ),
  );
}