function ResourceTypeBuildEvent::disableField

Same name in other branches
  1. 9 core/modules/jsonapi/src/ResourceType/ResourceTypeBuildEvent.php \Drupal\jsonapi\ResourceType\ResourceTypeBuildEvent::disableField()
  2. 8.9.x core/modules/jsonapi/src/ResourceType/ResourceTypeBuildEvent.php \Drupal\jsonapi\ResourceType\ResourceTypeBuildEvent::disableField()
  3. 11.x 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 145

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;
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.