You are here

public function ResourceTypeBuildEvent::disableField in Drupal 8

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

Disables the given field on the resource type to be built.

Parameters

\Drupal\jsonapi\ResourceType\ResourceTypeField $field: The field for which to set a public name.

File

core/modules/jsonapi/src/ResourceType/ResourceTypeBuildEvent.php, line 133

Class

ResourceTypeBuildEvent
An event used to configure the construction of a JSON:API resource type.

Namespace

Drupal\jsonapi\ResourceType

Code

public function disableField(ResourceTypeField $field) {
  foreach ($this->fields as $index => $value) {
    if ($field === $value) {
      $this->fields[$index] = $value
        ->disabled();
      return;
    }
  }
}