You are here

public function ContentSynchronizerCommands::synchronizerAllExport in Content Synchronizer 8.2

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

Export all : bind together create Export, attach all node in & cslex.

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

Parameters

string $destination: Destination file.

File

src/Commands/ContentSynchronizerCommands.php, line 251

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);
}