public function ResourceType::__construct in JSON:API 8.2
Same name and namespace in other branches
- 8 src/ResourceType/ResourceType.php \Drupal\jsonapi\ResourceType\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.
array $field_mapping: (optional) The field mapping to use.
File
- src/
ResourceType/ ResourceType.php, line 313
Class
- ResourceType
- Value object containing all metadata for a JSON:API resource type.
Namespace
Drupal\jsonapi\ResourceTypeCode
public function __construct($entity_type_id, $bundle, $deserialization_target_class, $internal = FALSE, $is_locatable = TRUE, $is_mutable = TRUE, $is_versionable = FALSE, array $field_mapping = []) {
$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->typeName = $this->bundle === '?' ? 'unknown' : sprintf('%s--%s', $this->entityTypeId, $this->bundle);
$this->fields = array_keys($field_mapping);
$this->disabledFields = array_keys(array_filter($field_mapping, function ($v) {
return $v === FALSE;
}));
$this->fieldMapping = array_filter($field_mapping, 'is_string');
$this->invertedFieldMapping = array_flip($this->fieldMapping);
}