You are here

public function ContentSynchronizerCommands::synchronizerAllExport in Content Synchronizer 8

Same name and namespace in other branches
  1. 8.2 src/Commands/ContentSynchronizerCommands.php \Drupal\content_synchronizer\Commands\ContentSynchronizerCommands::synchronizerAllExport()

Export all nodes/taxo : bind together create Export, attach all node in & cslex

@command content:synchronizer-export-all @aliases csexall

Parameters

$destination: Destination file

File

src/Commands/ContentSynchronizerCommands.php, line 217

Class

ContentSynchronizerCommands
A Drush commandfile.

Namespace

Drupal\content_synchronizer\Commands

Code

public function synchronizerAllExport($destination = '') {

  // 1 : create export
  $exportEntity = ExportEntity::create([
    'name' => 'export-all',
  ]);
  $exportEntity
    ->save();
  $exportId = $exportEntity
    ->id();

  // 2 : add all nodes / taxo
  foreach ([
    'node',
    'taxonomy_term',
  ] as $entity_type) {
    $ids = \Drupal::entityQuery($entity_type)
      ->execute();
    $entities = \Drupal::entityTypeManager()
      ->getStorage($entity_type)
      ->loadMultiple($ids);
    foreach ($entities as $entity) {
      $exportEntity
        ->addEntity($entity);
    }
  }

  // 3 : make export
  $this
    ->synchronizerLaunchExport($exportId, $destination);
}