ResourceObjectData.php in Drupal 10
File
core/modules/jsonapi/src/JsonApiResource/ResourceObjectData.php
View source
<?php
namespace Drupal\jsonapi\JsonApiResource;
use Drupal\Component\Assertion\Inspector;
use Drupal\jsonapi\Exception\EntityAccessDeniedHttpException;
class ResourceObjectData extends Data implements TopLevelDataInterface {
public function __construct($data, $cardinality = -1) {
assert(Inspector::assertAllObjects($data, ResourceObject::class, EntityAccessDeniedHttpException::class));
parent::__construct($data, $cardinality);
}
public function getData() {
return $this
->getAccessible();
}
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);
}
public function getOmissions() {
$omitted_data = [];
foreach ($this->data as $resource_object) {
if ($resource_object instanceof EntityAccessDeniedHttpException) {
$omitted_data[] = $resource_object;
}
}
return new OmittedData($omitted_data);
}
public function getMergedLinks(LinkCollection $top_level_links) {
return $top_level_links;
}
public function getMergedMeta(array $top_level_meta) {
return $top_level_meta;
}
}