You are here

public function MetatagManager::tagsFromEntity in Metatag 8

Extracts all tags of a given entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The content entity to extract meta tags from.

Return value

array Array of metatags.

Overrides MetatagManagerInterface::tagsFromEntity

1 call to MetatagManager::tagsFromEntity()
MetatagManager::tagsFromEntityWithDefaults in src/MetatagManager.php
Extracts all tags of a given entity.

File

src/MetatagManager.php, line 113

Class

MetatagManager
Class MetatagManager.

Namespace

Drupal\metatag

Code

public function tagsFromEntity(ContentEntityInterface $entity) {
  $tags = [];
  $fields = $this
    ->getFields($entity);

  /* @var \Drupal\field\Entity\FieldConfig $field_info */
  foreach ($fields as $field_name => $field_info) {

    // Get the tags from this field.
    $tags = $this
      ->getFieldTags($entity, $field_name);
  }
  return $tags;
}