From 6a438d5672285a38cbb4de2741b02e3631649b19 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Mon, 14 Oct 2024 13:52:07 +0200 Subject: [PATCH] create folder if not exists in migration command --- .../Command/ConvertExportDefinitionsToYaml.php | 6 ++++++ .../Command/ConvertImportDefinitionsToYaml.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/DataDefinitionsBundle/Command/ConvertExportDefinitionsToYaml.php b/src/DataDefinitionsBundle/Command/ConvertExportDefinitionsToYaml.php index 5de979d9..7c67a207 100644 --- a/src/DataDefinitionsBundle/Command/ConvertExportDefinitionsToYaml.php +++ b/src/DataDefinitionsBundle/Command/ConvertExportDefinitionsToYaml.php @@ -6,6 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Yaml\Yaml; class ConvertExportDefinitionsToYaml extends Command @@ -25,6 +26,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $filePath = $input->getArgument('file'); $data = require $filePath; + $fs = new Filesystem(); + if (!$fs->exists('var/config/export-definitions')) { + $fs->mkdir('var/config/export-definitions'); + } + foreach ($data as $entry) { $fileName = $entry['id'] . '.yaml'; diff --git a/src/DataDefinitionsBundle/Command/ConvertImportDefinitionsToYaml.php b/src/DataDefinitionsBundle/Command/ConvertImportDefinitionsToYaml.php index c21bf20c..16ea8d38 100644 --- a/src/DataDefinitionsBundle/Command/ConvertImportDefinitionsToYaml.php +++ b/src/DataDefinitionsBundle/Command/ConvertImportDefinitionsToYaml.php @@ -6,6 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Yaml\Yaml; class ConvertImportDefinitionsToYaml extends Command @@ -24,6 +25,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $filePath = $input->getArgument('file'); $data = require $filePath; + $fs = new Filesystem(); + if (!$fs->exists('var/config/import-definitions')) { + $fs->mkdir('var/config/import-definitions'); + } + foreach ($data as $entry) { $fileName = $entry['id'] . '.yaml';