diff --git a/docroot/modules/custom/va_gov_content_export/src/Archive/ArchiveDirectory.php b/docroot/modules/custom/va_gov_content_export/src/Archive/ArchiveDirectory.php index 8c9bcc7d13..986a3ea434 100644 --- a/docroot/modules/custom/va_gov_content_export/src/Archive/ArchiveDirectory.php +++ b/docroot/modules/custom/va_gov_content_export/src/Archive/ArchiveDirectory.php @@ -61,7 +61,7 @@ public function __construct(Zippy $zippy, FileSystemInterface $fileSystem, Conta */ public function archive(ArchiveArgs $archiveArgs) : ArchiveInterface { // @TODO Add locking/queueing/waiting so only one archive is occurring at a time. - $output_dir = dirname($archiveArgs->getOutputPath()); + $output_dir = $this->fileSystem->dirname($archiveArgs->getOutputPath()); $this->fileSystem->prepareDirectory($output_dir, FileSystemInterface::CREATE_DIRECTORY); $input_path = $this->fileSystem->realpath($archiveArgs->getCurrentWorkingDirectory()); diff --git a/docroot/modules/custom/va_gov_content_export/src/Controller/ContentExport.php b/docroot/modules/custom/va_gov_content_export/src/Controller/ContentExport.php index abb8af06d9..86e0ff1799 100644 --- a/docroot/modules/custom/va_gov_content_export/src/Controller/ContentExport.php +++ b/docroot/modules/custom/va_gov_content_export/src/Controller/ContentExport.php @@ -8,6 +8,7 @@ use Drupal\va_gov_content_export\Archive\ArchiveArgs; use Drupal\va_gov_content_export\Archive\ArchiveArgsFactory; use Drupal\va_gov_content_export\Archive\ArchiveDirectory; +use Drupal\va_gov_content_export\SiteStatus\SiteStatusInterface; use Exception; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -47,6 +48,13 @@ class ContentExport extends ControllerBase { */ public const ALLOWED_EXPORT_TYPES = ['content', 'asset']; + /** + * Site Status. + * + * @var \Drupal\va_gov_content_export\SiteStatus\SiteStatusInterface + */ + private $siteStatus; + /** * ContentExport constructor. * @@ -56,11 +64,14 @@ class ContentExport extends ControllerBase { * Kill switch. * @param \Drupal\va_gov_content_export\Archive\ArchiveArgsFactory $archiveArgsFactory * The Archive Args factory. + * @param \Drupal\va_gov_content_export\SiteStatus\SiteStatusInterface $siteStatus + * The Site Status Service. */ - public function __construct(ArchiveDirectory $archiver, KillSwitch $killSwitch, ArchiveArgsFactory $archiveArgsFactory) { + public function __construct(ArchiveDirectory $archiver, KillSwitch $killSwitch, ArchiveArgsFactory $archiveArgsFactory, SiteStatusInterface $siteStatus) { $this->archiver = $archiver; $this->killSwitch = $killSwitch; $this->archiveArgsFactory = $archiveArgsFactory; + $this->siteStatus = $siteStatus; } /** @@ -70,7 +81,8 @@ public static function create(ContainerInterface $container) { return new static( $container->get('va_gov.content_export.archive_directory'), $container->get('page_cache_kill_switch'), - $container->get('va_gov.content_export.archive_args_factory') + $container->get('va_gov.content_export.archive_args_factory'), + $container->get('va_gov.site_status') ); } @@ -97,7 +109,9 @@ public function redirectToFile(string $export_type) : Response { $this->killSwitch->trigger(); try { $archive_args = $this->getArchiveArgs($export_type); - $this->archiver->archive($archive_args); + if (!$this->siteStatus->inDeployMode()) { + $this->archiver->archive($archive_args); + } $file_name = $archive_args->getOutputPath(); if (!file_exists($file_name)) { diff --git a/docroot/modules/custom/va_gov_content_export/src/SiteStatus/SiteStatus.php b/docroot/modules/custom/va_gov_content_export/src/SiteStatus/SiteStatus.php new file mode 100644 index 0000000000..97fe805aed --- /dev/null +++ b/docroot/modules/custom/va_gov_content_export/src/SiteStatus/SiteStatus.php @@ -0,0 +1,19 @@ +