You are here

protected static function NodeExport::getNodesArray in Node export 8

Prepares an array of field-value pairs of nodes.

Parameters

int[] $ids: The ids of the nodes to be exported.

Return value

array An array of field-value pairs of nodes.

1 call to NodeExport::getNodesArray()
NodeExport::export in src/NodeExport.php
Exports nodes to a specified format to a file/code.

File

src/NodeExport.php, line 35

Class

NodeExport
Provides a Node Export function.

Namespace

Drupal\node_export

Code

protected static function getNodesArray(array $ids) {
  $nodes = empty($ids) ? Node::loadMultiple() : Node::loadMultiple($ids);
  $index = 0;
  $nodesArray = [];
  foreach ($nodes as $node) {
    foreach ($node as $key => $value) {
      $nodesArray[$index][$key] = $node
        ->get($key)
        ->getValue();
    }
    $index++;
  }
  return $nodesArray;
}