You are here

public function ResourceType::hasField in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/src/ResourceType/ResourceType.php \Drupal\jsonapi\ResourceType\ResourceType::hasField()

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 core/modules/jsonapi/src/ResourceType/ResourceType.php
Checks if a field is enabled or not.

File

core/modules/jsonapi/src/ResourceType/ResourceType.php, line 237

Class

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

Namespace

Drupal\jsonapi\ResourceType

Code

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