You are here

public function MetatagManager::generateElements in Metatag 8

Generate the elements that go in the hook_page_attachments attached array.

Parameters

array $tags: The array of tags as plugin_id => value.

object $entity: Optional entity object to use for token replacements.

Return value

array Render array with tag elements.

File

src/MetatagManager.php, line 491

Class

MetatagManager
Class MetatagManager.

Namespace

Drupal\metatag

Code

public function generateElements(array $tags, $entity = NULL) {
  $elements = [];
  $tags = $this
    ->generateRawElements($tags, $entity);
  foreach ($tags as $name => $tag) {
    if (!empty($tag)) {
      $elements['#attached']['html_head'][] = [
        $tag,
        $name,
      ];
    }
  }
  return $elements;
}