You are here

public function TermFieldAutocomplete::isTermFieldStorageConfig in GraphQL 8.4

Whether given field storage config is configured for term field.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $field_storage_config: The field storage config to be examined.

Return value

bool True if given field storage config is configured for term field.

1 call to TermFieldAutocomplete::isTermFieldStorageConfig()
TermFieldAutocomplete::getTermFieldVocabularies in src/Plugin/GraphQL/DataProducer/Taxonomy/TermFieldAutocomplete.php
Gets the vocabularies configured for given field if it is a term field.

File

src/Plugin/GraphQL/DataProducer/Taxonomy/TermFieldAutocomplete.php, line 190

Class

TermFieldAutocomplete
Gets term items matching the given string in given field's vocabularies.

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer\Taxonomy

Code

public function isTermFieldStorageConfig(FieldStorageDefinitionInterface $field_storage_config) : bool {

  // Term level field is allowed.
  $field_type = $field_storage_config
    ->getType();
  if ($field_type == 'term_level') {
    return TRUE;
  }

  // And term reference fields are allowed as well. Must be type of entity
  // reference or entity reference revision and must target taxonomy terms.
  if ($field_type != 'entity_reference' && $field_type != 'entity_reference_revisions') {
    return FALSE;
  }
  if ($field_storage_config
    ->getSetting('target_type') != 'taxonomy_term') {
    return FALSE;
  }
  return TRUE;
}