function ResourceObjectData::getAccessible

Same name in other branches
  1. 9 core/modules/jsonapi/src/JsonApiResource/ResourceObjectData.php \Drupal\jsonapi\JsonApiResource\ResourceObjectData::getAccessible()
  2. 8.9.x core/modules/jsonapi/src/JsonApiResource/ResourceObjectData.php \Drupal\jsonapi\JsonApiResource\ResourceObjectData::getAccessible()
  3. 11.x 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);
}

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