function ResourceType::__construct

Instantiates a ResourceType object.

Parameters

string $entity_type_id: An entity type ID.

string $bundle: A bundle.

string $deserialization_target_class: The deserialization target class.

bool $internal: (optional) Whether the resource type should be internal.

bool $is_locatable: (optional) Whether the resource type is locatable.

bool $is_mutable: (optional) Whether the resource type is mutable.

bool $is_versionable: (optional) Whether the resource type is versionable.

\Drupal\jsonapi\ResourceType\ResourceTypeField[] $fields: (optional) The resource type fields, keyed by internal field name.

File

core/modules/jsonapi/src/ResourceType/ResourceType.php, line 346

Class

ResourceType
Value object containing all metadata for a JSON:API resource type.

Namespace

Drupal\jsonapi\ResourceType

Code

public function __construct($entity_type_id, $bundle, $deserialization_target_class, $internal = FALSE, $is_locatable = TRUE, $is_mutable = TRUE, $is_versionable = FALSE, array $fields = []) {
  if (!empty($fields) && !reset($fields) instanceof ResourceTypeField) {
    $fields = $this->updateDeprecatedFieldMapping($fields, $entity_type_id, $bundle);
  }
  $this->entityTypeId = $entity_type_id;
  $this->bundle = $bundle;
  $this->deserializationTargetClass = $deserialization_target_class;
  $this->internal = $internal;
  $this->isLocatable = $is_locatable;
  $this->isMutable = $is_mutable;
  $this->isVersionable = $is_versionable;
  $this->fields = $fields;
  $this->typeName = $this->bundle === '?' ? 'unknown' : sprintf('%s--%s', $this->entityTypeId, $this->bundle);
  $this->fieldMapping = array_flip(array_map(function (ResourceTypeField $field) {
    return $field->getPublicName();
  }, $this->fields));
}

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