You are here

public function Exporter::writeDefaultContent in Default Content for D8 8

Writes an array of serialized entities to a given folder.

Parameters

string[][] $serialized_by_type: An array of serialized entities keyed by entity type and UUID.

string $folder: The folder to write files into.

Overrides ExporterInterface::writeDefaultContent

File

src/Exporter.php, line 227

Class

Exporter
A service for handling import of default content.

Namespace

Drupal\default_content

Code

public function writeDefaultContent(array $serialized_by_type, $folder) {
  foreach ($serialized_by_type as $entity_type => $serialized_entities) {

    // Ensure that the folder per entity type exists.
    $entity_type_folder = "{$folder}/{$entity_type}";
    $this
      ->prepareDirectory($entity_type_folder);
    foreach ($serialized_entities as $uuid => $serialized_entity) {
      $this
        ->putFile($entity_type_folder, $uuid, $serialized_entity);
    }
  }
}