You are here

public function ResourceType::hasField in JSON:API 8.2

Checks if the field exists.

Note: a minority of config entity types which do not define a `config_export` in their entity type annotation will not have their fields represented here because it is impossible to determine them without an instance of config available.

@todo Refactor this in Drupal 9, because thanks to https://www.drupal.org/project/drupal/issues/2949021, `config_export` will be guaranteed to exist, and this won't need an instance anymore.

Parameters

string $field_name: The internal field name.

Return value

bool TRUE if the field is known to exist on the resource type; FALSE otherwise.

1 call to ResourceType::hasField()
ResourceType::isFieldEnabled in src/ResourceType/ResourceType.php
Checks if a field is enabled or not.

File

src/ResourceType/ResourceType.php, line 201

Class

ResourceType
Value object containing all metadata for a JSON:API resource type.

Namespace

Drupal\jsonapi\ResourceType

Code

public function hasField($field_name) {
  return in_array($field_name, $this->fields, TRUE);
}