25 private $subdirectoryPath =
'analytics/';
32 private $archiveName =
'data.tgz';
49 private $reportWriter;
56 private $cryptographer;
63 private $fileRecorder;
80 $this->archive = $archive;
81 $this->reportWriter = $reportWriter;
82 $this->cryptographer = $cryptographer;
83 $this->fileRecorder = $fileRecorder;
94 $this->prepareDirectory(
$tmpDirectory, $this->getTmpFilesDirRelativePath());
95 $this->reportWriter->write(
$tmpDirectory, $this->getTmpFilesDirRelativePath());
97 $tmpFilesDirectoryAbsolutePath = $this->validateSource(
$tmpDirectory, $this->getTmpFilesDirRelativePath());
98 $archiveAbsolutePath = $this->prepareFileDirectory(
$tmpDirectory, $this->getArchiveRelativePath());
100 $tmpFilesDirectoryAbsolutePath,
104 $this->validateSource(
$tmpDirectory, $this->getArchiveRelativePath());
105 $this->fileRecorder->recordNewFile(
106 $this->cryptographer->encode(
$tmpDirectory->readFile($this->getArchiveRelativePath()))
121 private function getTmpFilesDirRelativePath()
123 return $this->subdirectoryPath .
'tmp/';
131 private function getArchiveRelativePath()
133 return $this->subdirectoryPath . $this->archiveName;
143 private function prepareDirectory(WriteInterface $directory,
$path)
145 $directory->delete(
$path);
147 return $directory->getAbsolutePath(
$path);
157 private function prepareFileDirectory(WriteInterface $directory,
$path)
159 $directory->delete(
$path);
160 if (dirname(
$path) !==
'.') {
161 $directory->create(dirname(
$path));
164 return $directory->getAbsolutePath(
$path);
174 private function pack(
$source, $destination)
176 $this->archive->pack(
195 private function validateSource(WriteInterface $directory,
$path)
197 if (!$directory->isExist(
$path)) {
198 throw new LocalizedException(
__(
'The "%1" source doesn\'t exist.', $directory->getAbsolutePath(
$path)));
201 return $directory->getAbsolutePath(
$path);
__construct(Filesystem $filesystem, Archive $archive, ReportWriterInterface $reportWriter, Cryptographer $cryptographer, FileRecorder $fileRecorder)