You are here

public function MetatagQuery::getMetatagFields in GatherContent 8.4

Same name and namespace in other branches
  1. 8.5 src/MetatagQuery.php \Drupal\gathercontent\MetatagQuery::getMetatagFields()

Get list of metatag fields.

Parameters

string $content_type: Machine name of content type.

Return value

array Array of metatag fields.

File

src/MetatagQuery.php, line 62

Class

MetatagQuery
Class for querying metatag data.

Namespace

Drupal\gathercontent

Code

public function getMetatagFields($content_type) {
  $instances = $this->entityFieldManager
    ->getFieldDefinitions('node', $content_type);
  $fields = [];
  foreach ($instances as $name => $instance) {

    /** @var \Drupal\Core\Field\FieldDefinitionInterface $instance */
    if ($instance
      ->getType() === 'metatag') {
      $fields[] = $instance
        ->getName();
    }
  }
  return $fields;
}