You are here

public function ResourceObjectData::getAccessible in Drupal 9

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

Gets only data to be exposed.

Return value

static

1 call to ResourceObjectData::getAccessible()
ResourceObjectData::getData in core/modules/jsonapi/src/JsonApiResource/ResourceObjectData.php
Returns the data for the top-level data member of a JSON:API document.

File

core/modules/jsonapi/src/JsonApiResource/ResourceObjectData.php, line 46

Class

ResourceObjectData
Represents the primary data for individual and collection documents.

Namespace

Drupal\jsonapi\JsonApiResource

Code

public function getAccessible() {
  $accessible_data = [];
  foreach ($this->data as $resource_object) {
    if (!$resource_object instanceof EntityAccessDeniedHttpException) {
      $accessible_data[] = $resource_object;
    }
  }
  return new static($accessible_data, $this->cardinality);
}