You are here

protected static function NodeImport::unload in Node export 8

Prepares a field-value array for the node to be imported.

Parameters

array $nodeArray: An exported node array.

Return value

array|bool Returns an array containing field-value pairs of the node or FALSE.

1 call to NodeImport::unload()
NodeImport::import in src/NodeImport.php
Imports a node with given field-value array.

File

src/NodeImport.php, line 22

Class

NodeImport
Provides a Node Import function.

Namespace

Drupal\node_export

Code

protected static function unload(array $nodeArray) {
  $fieldValues = [];
  $contentType = $nodeArray['type'][0]['target_id'];
  if (self::contentTypeExists($contentType)) {
    $bundleFields = \Drupal::service('entity_field.manager')
      ->getFieldDefinitions('node', $contentType);
    foreach ($nodeArray as $fields => $value) {
      if (!array_key_exists($fields, $bundleFields)) {
        return FALSE;
      }
      $fieldValues[$fields] = $value;
    }
    $fieldValues['type'] = $contentType;
  }
  return $fieldValues;
}