You are here

public function ExportEntityWriter::addRepToArchive in Content Synchronizer 3.x

Same name and namespace in other branches
  1. 8.2 src/Processors/ExportEntityWriter.php \Drupal\content_synchronizer\Processors\ExportEntityWriter::addRepToArchive()

Add files to archive recursively.

Parameters

string $repPath: The repertory path.

string $parent: The parent.

\Drupal\Core\Archiver\ArchiveTar $archiver: The archiver.

1 call to ExportEntityWriter::addRepToArchive()
ExportEntityWriter::archiveFiles in src/Processors/ExportEntityWriter.php
Zip the generated files.

File

src/Processors/ExportEntityWriter.php, line 195

Class

ExportEntityWriter
Export entity writer.

Namespace

Drupal\content_synchronizer\Processors

Code

public function addRepToArchive($repPath, $parent, ArchiveTar $archiver) {
  $files = \scandir($repPath);
  foreach ($files as $file) {
    if (!in_array($file, [
      '.',
      '..',
    ])) {
      if (is_dir($repPath . '/' . $file)) {
        $this
          ->addRepToArchive($repPath . '/' . $file, $parent . '/' . $file, $archiver);
      }
      else {
        $archiver
          ->addString($parent . '/' . $file, file_get_contents($repPath . '/' . $file));
      }
    }
  }
}