You are here

function drush_default_content_export in Default Content for D8 8

Same name and namespace in other branches
  1. 2.0.x drush/default_content.drush.inc \drush_default_content_export()

Exports a piece of content into the stdout or into a file.

Parameters

string $entity_type_id: The entity type ID.

mixed $entity_id: The entity ID to export.

File

drush/default_content.drush.inc, line 56
Drush integration for the default_content module.

Code

function drush_default_content_export($entity_type_id, $entity_id) {

  /** @var \Drupal\default_content\DefaultContentExporterInterface $exporter */
  $exporter = \Drupal::service('default_content.exporter');
  $export = $exporter
    ->exportContent($entity_type_id, $entity_id);
  if ($file = drush_get_option('file')) {
    file_put_contents($file, $export);
  }
  else {
    drush_print($export);
  }
}