You are here

protected function JsonapiHelper::prepareEntityData in Entity Share 8.2

Same name and namespace in other branches
  1. 8 modules/entity_share_client/src/Service/JsonapiHelper.php \Drupal\entity_share_client\Service\JsonapiHelper::prepareEntityData()

Prepare the data array before extracting the entity.

Used to remove some data.

Parameters

array $data: An array of data.

array $entity_keys: An array of entity keys.

1 call to JsonapiHelper::prepareEntityData()
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 845

Class

JsonapiHelper
Class JsonapiHelper.

Namespace

Drupal\entity_share_client\Service

Code

protected function prepareEntityData(array &$data, array $entity_keys) {
  $parsed_type = explode('--', $data['type']);
  $resource_type = $this->resourceTypeRepository
    ->get($parsed_type[0], $parsed_type[1]);

  // Removes some ids.
  unset($data['attributes'][$resource_type
    ->getPublicName($entity_keys['id'])]);
  if (isset($entity_keys['revision']) && !empty($entity_keys['revision'])) {
    unset($data['attributes'][$resource_type
      ->getPublicName($entity_keys['revision'])]);
  }

  // UUID is no longer included as attribute.
  $data['attributes'][$resource_type
    ->getPublicName($entity_keys['uuid'])] = $data['id'];

  // Remove the default_langcode boolean to be able to import content not
  // necessarily in the default language.
  unset($data['attributes'][$resource_type
    ->getPublicName($entity_keys['default_langcode'])]);
}