Skip to content

Commit

Permalink
Create picture target directory during import if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilPeyssard authored and juchi committed Nov 10, 2022
1 parent e539680 commit b4b9b30
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Command/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ private function init(InputInterface $input)
$this->importManager->setFilesDirectory($filesDir);
}

$targetDir = $this->configurationManager->getImageDirectory();
if (!file_exists($targetDir) && !mkdir($targetDir, 0755)) {
throw new \Exception($this->translator->trans(
'init.errors.cannot_create_directory',
['%path%' => $targetDir],
'AdvancedContentBundle'
));
}

$allowUpdate = $this->configurationManager->initCanUpdate();
if ($input->getOption('update') === true) {
$allowUpdate = true;
Expand Down
1 change: 1 addition & 0 deletions Resources/translations/AdvancedContentBundle.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ init:
unknown_entity_type: Entity type "%type%" is unknown. Available entities are %list%.
file_not_found: File %file% was not found in directory "%dir%"
field_value_entity_not_found: Entity with identifier "%value%" was not found for field
cannot_create_directory: Unable to create directory "%path%"
export_success: Files were successfully exported in "%dir%"
tools:
label: Tools
Expand Down
1 change: 1 addition & 0 deletions Resources/translations/AdvancedContentBundle.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ init:
unknown_entity_type: Le type "%type%" est inconnu. Les types d'entité disponibles sont %list%.
file_not_found: Le fichier %file% n'a pas été trouvé dans le dossier "%dir%"
field_value_entity_not_found: Aucune entité avec identifiant "%value%" n'a été trouvée pour le champ "%slug%"
cannot_create_directory: Impossible de créer le répertoire "%path%"
export_success: Les fichiers ont bien été exportés dans "%dir%"
tools:
label: Outils
Expand Down

0 comments on commit b4b9b30

Please sign in to comment.