You are here

public function MetatagQuery::checkMetatag in GatherContent 8.5

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

Check if content type has any metatag fields.

Parameters

string $entityType: Machine name of the entity type.

string $contentType: Machine name of content type.

Return value

bool TRUE if metatag field exists.

File

src/MetatagQuery.php, line 61

Class

MetatagQuery
Class for querying metatag data.

Namespace

Drupal\gathercontent

Code

public function checkMetatag($entityType, $contentType) {
  $instances = $this->entityFieldManager
    ->getFieldDefinitions($entityType, $contentType);
  foreach ($instances as $instance) {

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