public function MetatagQuery::getFirstMetatagField in GatherContent 8.5
Get the first metatag field.
Parameters
string $entityType: Machine name of the entity type.
string $contentType: Machine name of content type.
Return value
string Metatag field name.
File
- src/
MetatagQuery.php, line 85
Class
- MetatagQuery
- Class for querying metatag data.
Namespace
Drupal\gathercontentCode
public function getFirstMetatagField($entityType, $contentType) {
$instances = $this->entityFieldManager
->getFieldDefinitions($entityType, $contentType);
foreach ($instances as $instance) {
/** @var \Drupal\Core\Field\FieldDefinitionInterface $instance */
if ($instance
->getType() === 'metatag') {
return $instance
->getName();
}
}
return '';
}