You are here

protected function JsonapiHelper::prepareEntityData in Entity Share 8

Same name and namespace in other branches
  1. 8.2 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 JSONAPI to import content.

File

modules/entity_share_client/src/Service/JsonapiHelper.php, line 631

Class

JsonapiHelper
Class JsonapiHelper.

Namespace

Drupal\entity_share_client\Service

Code

protected function prepareEntityData(array &$data, array $entity_keys) {

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

  // Remove the default_langcode boolean to be able to import content not
  // necessarily in the default language.
  // TODO: Handle content_translation_source?
  unset($data['attributes'][$entity_keys['default_langcode']]);

  // To avoid side effects and as currently JSONAPI send null for the path
  // we remove the path attribute.
  if (isset($data['attributes']['path'])) {
    unset($data['attributes']['path']);
  }
}