public function JsonapiHelper::extractEntity in Entity Share 8.2
Same name and namespace in other branches
- 8.3 modules/entity_share_client/src/Service/JsonapiHelper.php \Drupal\entity_share_client\Service\JsonapiHelper::extractEntity()
- 8 modules/entity_share_client/src/Service/JsonapiHelper.php \Drupal\entity_share_client\Service\JsonapiHelper::extractEntity()
Helper function to unserialize an entity from the JSON:API response.
Parameters
array $data: An array of data.
Return value
\Drupal\Core\Entity\EntityInterface An unserialize entity.
Overrides JsonapiHelperInterface::extractEntity
1 call to JsonapiHelper::extractEntity()
- JsonapiHelper::importEntityListData in modules/
entity_share_client/ src/ Service/ JsonapiHelper.php - Use data from the JSON:API to import content.
File
- modules/
entity_share_client/ src/ Service/ JsonapiHelper.php, line 273
Class
- JsonapiHelper
- Class JsonapiHelper.
Namespace
Drupal\entity_share_client\ServiceCode
public function extractEntity(array $data) {
// Format JSON as in
// JsonApiDocumentTopLevelNormalizerTest::testDenormalize().
$prepared_json = [
'data' => [
'type' => $data['type'],
'attributes' => $data['attributes'],
],
];
$parsed_type = explode('--', $data['type']);
return $this->jsonapiDocumentTopLevelNormalizer
->denormalize($prepared_json, NULL, 'api_json', [
'resource_type' => $this->resourceTypeRepository
->get($parsed_type[0], $parsed_type[1]),
]);
}