From 6046ac0b34bfbbc743fab7e13775443eba2d7d6f Mon Sep 17 00:00:00 2001 From: Dominik Date: Mon, 27 May 2024 07:44:26 +0200 Subject: [PATCH 1/6] Allow Symfony 7 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b5a9178d..c748ff22 100755 --- a/composer.json +++ b/composer.json @@ -42,8 +42,8 @@ "pimcore/pimcore": "^11.0", "psr/http-client-implementation": "^1.0", "psr/http-factory-implementation": "^1.0", - "symfony/dotenv": "^6.3", - "symfony/http-client": "^6.3" + "symfony/dotenv": "^6.3 | ^7.0", + "symfony/http-client": "^6.3 | ^7.0" }, "require-dev": { "roave/security-advisories": "dev-latest", From 19e45f3076b52eb7015e7c67af6bcc288e0e3e6c Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Mon, 27 May 2024 07:52:59 +0200 Subject: [PATCH 2/6] fix definition interpreter --- src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php b/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php index 8fc02a2c..b9fd55f2 100644 --- a/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php +++ b/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php @@ -34,7 +34,7 @@ public function __construct(RepositoryInterface $definitionRepository, ImporterI } public function interpret(InterpreterContextInterface $context): mixed { - $subDefinition = $this->definitionRepository->find($context->getConfiguration()['definition']); + $subDefinition = $this->definitionRepository->find((string)$context->getConfiguration()['definition']); if (!$subDefinition instanceof ImportDefinitionInterface) { return null; From b25348a21ace899d6bf8ec931ae70cbacf41f57d Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Mon, 27 May 2024 07:56:05 +0200 Subject: [PATCH 3/6] update tests --- .github/workflows/behat.yml | 8 ++++---- .github/workflows/static.yml | 4 ++-- .../Interpreter/DefinitionInterpreter.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/behat.yml b/.github/workflows/behat.yml index a1f12ba6..6fa84c75 100644 --- a/.github/workflows/behat.yml +++ b/.github/workflows/behat.yml @@ -43,7 +43,7 @@ jobs: name: "${{ matrix.pimcore }}, PHP ${{ matrix.php }}, Deps ${{ matrix.dependencies }}" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -64,7 +64,7 @@ jobs: run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -98,7 +98,7 @@ jobs: run: vendor/bin/behat --strict --no-interaction -vvv -f progress --config behat.yml.dist -p default - name: Upload Behat logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: failure() with: name: "Behat logs (non-JS, PHP ${{ matrix.php }}, Symfony ${{ matrix.pimcore }})" @@ -106,7 +106,7 @@ jobs: if-no-files-found: ignore - name: Upload Pimcore logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: failure() with: name: "Pimcore logs (non-JS, PHP ${{ matrix.php }}, Symfony ${{ matrix.pimcore }})" diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index f8c3f1ed..18959379 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -34,7 +34,7 @@ jobs: name: "${{ matrix.pimcore }}, PHP ${{ matrix.php }}, Deps ${{ matrix.dependencies }}" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -51,7 +51,7 @@ jobs: run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} diff --git a/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php b/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php index b9fd55f2..a5b54d08 100644 --- a/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php +++ b/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php @@ -34,7 +34,7 @@ public function __construct(RepositoryInterface $definitionRepository, ImporterI } public function interpret(InterpreterContextInterface $context): mixed { - $subDefinition = $this->definitionRepository->find((string)$context->getConfiguration()['definition']); + $subDefinition = $this->definitionRepository->find((string)($context->getConfiguration()['definition'])); if (!$subDefinition instanceof ImportDefinitionInterface) { return null; From 4456ab7b334dd0b181b90c9a4e775ff4f727aa93 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Mon, 27 May 2024 08:01:36 +0200 Subject: [PATCH 4/6] fix definition interpreter --- .gitignore | 4 +++- .../Interpreter/DefinitionInterpreter.php | 2 +- src/DataDefinitionsBundle/Model/ExportDefinition.php | 2 +- src/DataDefinitionsBundle/Model/ImportDefinition.php | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 62faa52b..4a0facd3 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,6 @@ web public docker-compose.yaml test-commands.txt -.docker \ No newline at end of file +.docker +cache +config/pimcore/data-definitions \ No newline at end of file diff --git a/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php b/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php index a5b54d08..8fc02a2c 100644 --- a/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php +++ b/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php @@ -34,7 +34,7 @@ public function __construct(RepositoryInterface $definitionRepository, ImporterI } public function interpret(InterpreterContextInterface $context): mixed { - $subDefinition = $this->definitionRepository->find((string)($context->getConfiguration()['definition'])); + $subDefinition = $this->definitionRepository->find($context->getConfiguration()['definition']); if (!$subDefinition instanceof ImportDefinitionInterface) { return null; diff --git a/src/DataDefinitionsBundle/Model/ExportDefinition.php b/src/DataDefinitionsBundle/Model/ExportDefinition.php index fe5a0b7d..557a4760 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinition.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinition.php @@ -36,7 +36,7 @@ class ExportDefinition extends AbstractDataDefinition implements ExportDefinitio */ public $fetchUnpublished = false; - public static function getById(string $name) + public static function getById(int $name) { return static::getByName($name); } diff --git a/src/DataDefinitionsBundle/Model/ImportDefinition.php b/src/DataDefinitionsBundle/Model/ImportDefinition.php index d696ee70..79bfa2f0 100644 --- a/src/DataDefinitionsBundle/Model/ImportDefinition.php +++ b/src/DataDefinitionsBundle/Model/ImportDefinition.php @@ -86,7 +86,7 @@ class ImportDefinition extends AbstractDataDefinition implements ImportDefinitio */ public $persister; - public static function getById(string $name) + public static function getById(int $name) { return static::getByName($name); } From d7abbefbc4cb6c8270afde1598ab2f4393963611 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Mon, 27 May 2024 08:04:43 +0200 Subject: [PATCH 5/6] fix definition interpreter --- src/DataDefinitionsBundle/Model/ImportDefinition.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataDefinitionsBundle/Model/ImportDefinition.php b/src/DataDefinitionsBundle/Model/ImportDefinition.php index 79bfa2f0..bf898df5 100644 --- a/src/DataDefinitionsBundle/Model/ImportDefinition.php +++ b/src/DataDefinitionsBundle/Model/ImportDefinition.php @@ -88,10 +88,10 @@ class ImportDefinition extends AbstractDataDefinition implements ImportDefinitio public static function getById(int $name) { - return static::getByName($name); + return static::getByName((string)$name); } - public static function getByName($id) + public static function getByName(string $id) { $definitionEntry = new ImportDefinition(); $definitionEntry->setId((int)$id); From 76b2847c4ab33ad54fca4154af886574fb9c48b0 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Mon, 27 May 2024 08:26:34 +0200 Subject: [PATCH 6/6] fix definition interpreter --- composer.json | 4 ++-- .../Command/ImportAsyncCommand.php | 9 ++------- .../AbstractDefinitionController.php | 15 ++++++++++++++ .../Controller/ExportDefinitionController.php | 16 +++++++++------ .../Controller/ImportDefinitionController.php | 20 +++++++++++-------- .../DataDefinitionsBundle.php | 3 +-- .../Form/Type/DefinitionChoiceType.php | 14 ++++++------- .../Interpreter/DefinitionInterpreter.php | 20 +++++++++---------- .../Model/ImportDefinition/Dao.php | 2 +- .../ExportDefinitionStartupFormResolver.php | 11 +++++----- .../Provider/CsvProvider.php | 5 +++-- .../Repository/DefinitionRepository.php | 5 +++++ 12 files changed, 71 insertions(+), 53 deletions(-) diff --git a/composer.json b/composer.json index c748ff22..83213df5 100755 --- a/composer.json +++ b/composer.json @@ -31,14 +31,14 @@ "require": { "php": ">=8.1", "ext-json": "*", - "openspout/openspout": "^4.23", "coreshop/pimcore-bundle": "^4.0", "coreshop/resource-bundle": "^4.0", "coreshop/rule-bundle": "^4.0", "jms/serializer": "^3.17", "league/csv": "^9.7", "nyholm/psr7": "^1.5", - "pimcore/admin-ui-classic-bundle": "^1.0", + "openspout/openspout": "^4.23", + "pimcore/admin-ui-classic-bundle": "^1.4", "pimcore/pimcore": "^11.0", "psr/http-client-implementation": "^1.0", "psr/http-factory-implementation": "^1.0", diff --git a/src/DataDefinitionsBundle/Command/ImportAsyncCommand.php b/src/DataDefinitionsBundle/Command/ImportAsyncCommand.php index a1fd58bf..d74e908c 100644 --- a/src/DataDefinitionsBundle/Command/ImportAsyncCommand.php +++ b/src/DataDefinitionsBundle/Command/ImportAsyncCommand.php @@ -62,19 +62,14 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output) { - $eventDispatcher = $this->eventDispatcher; - $params = json_decode($input->getOption('params'), true); if (!isset($params['userId'])) { $params['userId'] = 0; } - try { - $definition = $this->repository->find($input->getOption('definition')); - } catch (InvalidArgumentException $e) { - $definition = $this->repository->findByName($input->getOption('definition')); - } + $inputDefinition = $input->getOption('definition'); + $definition = $this->repository->findByName((string)$inputDefinition); if (!$definition instanceof ImportDefinitionInterface) { throw new Exception('Import Definition not found'); diff --git a/src/DataDefinitionsBundle/Controller/AbstractDefinitionController.php b/src/DataDefinitionsBundle/Controller/AbstractDefinitionController.php index 3f49b1ce..8cf9e6de 100644 --- a/src/DataDefinitionsBundle/Controller/AbstractDefinitionController.php +++ b/src/DataDefinitionsBundle/Controller/AbstractDefinitionController.php @@ -18,6 +18,7 @@ use CoreShop\Bundle\ResourceBundle\Controller\ResourceController; use CoreShop\Component\Resource\Model\ResourceInterface; +use Instride\Bundle\DataDefinitionsBundle\Repository\DefinitionRepository; use Pimcore\Model\DataObject; use Pimcore\Tool; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -28,6 +29,9 @@ use Instride\Bundle\DataDefinitionsBundle\Model\ExportDefinitionInterface; use Instride\Bundle\DataDefinitionsBundle\Model\ExportMapping\FromColumn; +/** + * @property DefinitionRepository $repository + */ abstract class AbstractDefinitionController extends ResourceController { public function getAction(Request $request): JsonResponse @@ -38,4 +42,15 @@ public function getAction(Request $request): JsonResponse return $this->viewHandler->handle(['data' => $resources, 'success' => true], ['group' => 'Detailed']); } + + protected function findOr404(int|string $id): ResourceInterface + { + $model = $this->repository->findByName((string)$id); + + if (null === $model || !$model instanceof ResourceInterface) { + throw new NotFoundHttpException(sprintf('The "%s" has not been found', $id)); + } + + return $model; + } } diff --git a/src/DataDefinitionsBundle/Controller/ExportDefinitionController.php b/src/DataDefinitionsBundle/Controller/ExportDefinitionController.php index 895a8190..6b1b7e8d 100644 --- a/src/DataDefinitionsBundle/Controller/ExportDefinitionController.php +++ b/src/DataDefinitionsBundle/Controller/ExportDefinitionController.php @@ -17,6 +17,7 @@ namespace Instride\Bundle\DataDefinitionsBundle\Controller; use CoreShop\Bundle\ResourceBundle\Controller\ResourceController; +use Instride\Bundle\DataDefinitionsBundle\Repository\DefinitionRepository; use Pimcore\Model\DataObject; use Pimcore\Tool; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -27,6 +28,9 @@ use Instride\Bundle\DataDefinitionsBundle\Model\ExportDefinitionInterface; use Instride\Bundle\DataDefinitionsBundle\Model\ExportMapping\FromColumn; +/** + * @property DefinitionRepository $repository + */ class ExportDefinitionController extends AbstractDefinitionController { public function getConfigAction(): JsonResponse @@ -56,10 +60,10 @@ public function getConfigAction(): JsonResponse public function exportAction(Request $request): Response { - $id = (int)$request->get('id'); + $id = $request->get('id'); if ($id) { - $definition = $this->repository->find($id); + $definition = $this->repository->findByName($id); if ($definition instanceof ExportDefinitionInterface) { @@ -88,7 +92,7 @@ public function exportAction(Request $request): Response public function importAction(Request $request): JsonResponse { $id = (int)$request->get('id'); - $definition = $this->repository->find($id); + $definition = $this->repository->findByName($id); if ($id && $definition instanceof ExportDefinitionInterface && $request->files->has('Filedata')) { $uploadedFile = $request->files->get('Filedata'); @@ -116,8 +120,8 @@ public function importAction(Request $request): JsonResponse public function duplicateAction(Request $request): JsonResponse { - $id = (int)$request->get('id'); - $definition = $this->repository->find($id); + $id = $request->get('id'); + $definition = $this->repository->findByName($id); $name = (string)$request->get('name'); if ($definition instanceof ExportDefinitionInterface && $name) { @@ -137,7 +141,7 @@ public function duplicateAction(Request $request): JsonResponse public function getColumnsAction(Request $request): JsonResponse { $id = $request->get('id'); - $definition = $this->repository->find($id); + $definition = $this->repository->findByName($id); if (!$definition instanceof ExportDefinitionInterface || !$definition->getClass()) { return $this->viewHandler->handle(['success' => false]); diff --git a/src/DataDefinitionsBundle/Controller/ImportDefinitionController.php b/src/DataDefinitionsBundle/Controller/ImportDefinitionController.php index ba479883..b8545cd3 100644 --- a/src/DataDefinitionsBundle/Controller/ImportDefinitionController.php +++ b/src/DataDefinitionsBundle/Controller/ImportDefinitionController.php @@ -18,6 +18,7 @@ use CoreShop\Component\Registry\ServiceRegistryInterface; use Exception; +use Instride\Bundle\DataDefinitionsBundle\Repository\DefinitionRepository; use Pimcore\Model\DataObject; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -32,6 +33,9 @@ use Instride\Bundle\DataDefinitionsBundle\Service\FieldSelection; use function is_array; +/** + * @property DefinitionRepository $repository + */ class ImportDefinitionController extends AbstractDefinitionController { public function getConfigAction(): JsonResponse @@ -66,7 +70,7 @@ public function getConfigAction(): JsonResponse public function testDataAction(Request $request): JsonResponse { $id = $request->get('id'); - $definition = $this->repository->find($id); + $definition = $this->repository->findByName($id); if ($definition instanceof ImportDefinitionInterface) { try { @@ -88,7 +92,7 @@ public function testDataAction(Request $request): JsonResponse public function getColumnsAction(Request $request): JsonResponse { $id = $request->get('id'); - $definition = $this->repository->find($id); + $definition = $this->repository->findByName($id); if ($definition instanceof ImportDefinitionInterface && $definition->getClass()) { $customFromColumn = new FromColumn(); @@ -189,10 +193,10 @@ public function getColumnsAction(Request $request): JsonResponse public function exportAction(Request $request): Response { - $id = (int)$request->get('id'); + $id = $request->get('id'); if ($id) { - $definition = $this->repository->find($id); + $definition = $this->repository->findByName($id); if ($definition instanceof ImportDefinitionInterface) { @@ -220,8 +224,8 @@ public function exportAction(Request $request): Response public function importAction(Request $request): JsonResponse { - $id = (int)$request->get('id'); - $definition = $this->repository->find($id); + $id = $request->get('id'); + $definition = $this->repository->findByName($id); if ($id && $definition instanceof ImportDefinitionInterface && $request->files->has('Filedata')) { $uploadedFile = $request->files->get('Filedata'); @@ -249,8 +253,8 @@ public function importAction(Request $request): JsonResponse public function duplicateAction(Request $request): JsonResponse { - $id = (int)$request->get('id'); - $definition = $this->repository->find($id); + $id = $request->get('id'); + $definition = $this->repository->findByName($id); $name = (string)$request->get('name'); if ($definition instanceof ImportDefinitionInterface && $name) { diff --git a/src/DataDefinitionsBundle/DataDefinitionsBundle.php b/src/DataDefinitionsBundle/DataDefinitionsBundle.php index 9f751861..04d6094c 100644 --- a/src/DataDefinitionsBundle/DataDefinitionsBundle.php +++ b/src/DataDefinitionsBundle/DataDefinitionsBundle.php @@ -24,7 +24,6 @@ use Pimcore\Bundle\AdminBundle\PimcoreAdminBundle; use Pimcore\Bundle\SimpleBackendSearchBundle\PimcoreSimpleBackendSearchBundle; use Pimcore\Extension\Bundle\Installer\InstallerInterface; -use Pimcore\Extension\Bundle\PimcoreBundleInterface; use Pimcore\HttpKernel\BundleCollection\BundleCollection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Instride\Bundle\DataDefinitionsBundle\DependencyInjection\Compiler\CleanerRegistryCompilerPass; @@ -50,7 +49,7 @@ public static function registerDependentBundles(BundleCollection $collection): v $collection->addBundles([ new PimcoreAdminBundle(), - new PimcoreSimpleBackendSearchBundle() + new PimcoreSimpleBackendSearchBundle(), ]); $collection->addBundles([ diff --git a/src/DataDefinitionsBundle/Form/Type/DefinitionChoiceType.php b/src/DataDefinitionsBundle/Form/Type/DefinitionChoiceType.php index 4bae5872..de9da8e1 100644 --- a/src/DataDefinitionsBundle/Form/Type/DefinitionChoiceType.php +++ b/src/DataDefinitionsBundle/Form/Type/DefinitionChoiceType.php @@ -16,22 +16,20 @@ namespace Instride\Bundle\DataDefinitionsBundle\Form\Type; -use CoreShop\Component\Resource\Repository\RepositoryInterface; +use Instride\Bundle\DataDefinitionsBundle\Model\DataDefinitionInterface; +use Instride\Bundle\DataDefinitionsBundle\Repository\DefinitionRepository; use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -use Instride\Bundle\DataDefinitionsBundle\Model\DataDefinitionInterface; final class DefinitionChoiceType extends AbstractType { - private RepositoryInterface $definitionRepository; - - public function __construct(RepositoryInterface $definitionRepository) - { - $this->definitionRepository = $definitionRepository; + public function __construct( + private readonly DefinitionRepository $definitionRepository + ) { } public function buildForm(FormBuilderInterface $builder, array $options): void @@ -52,7 +50,7 @@ public function configureOptions(OptionsResolver $resolver): void }, $this->definitionRepository->findAll()); }, 'choice_label' => function ($val) { - $def = $this->definitionRepository->find($val); + $def = $this->definitionRepository->findByName($val); return $def !== null ? $def->getName() : null; }, diff --git a/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php b/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php index 8fc02a2c..228b6925 100644 --- a/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php +++ b/src/DataDefinitionsBundle/Interpreter/DefinitionInterpreter.php @@ -16,25 +16,23 @@ namespace Instride\Bundle\DataDefinitionsBundle\Interpreter; -use CoreShop\Component\Resource\Repository\RepositoryInterface; -use Pimcore\Model\DataObject; use Instride\Bundle\DataDefinitionsBundle\Context\InterpreterContextInterface; use Instride\Bundle\DataDefinitionsBundle\Importer\ImporterInterface; use Instride\Bundle\DataDefinitionsBundle\Model\ImportDefinitionInterface; +use Instride\Bundle\DataDefinitionsBundle\Repository\DefinitionRepository; +use Pimcore\Model\DataObject; class DefinitionInterpreter implements InterpreterInterface { - private RepositoryInterface $definitionRepository; - private ImporterInterface $importer; - - public function __construct(RepositoryInterface $definitionRepository, ImporterInterface $importer) - { - $this->definitionRepository = $definitionRepository; - $this->importer = $importer; + public function __construct( + private readonly DefinitionRepository $definitionRepository, + private readonly ImporterInterface $importer + ) { } - public function interpret(InterpreterContextInterface $context): mixed { - $subDefinition = $this->definitionRepository->find($context->getConfiguration()['definition']); + public function interpret(InterpreterContextInterface $context): mixed + { + $subDefinition = $this->definitionRepository->findByName($context->getConfiguration()['definition']); if (!$subDefinition instanceof ImportDefinitionInterface) { return null; diff --git a/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php b/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php index e78eedf0..ee219fd9 100644 --- a/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php +++ b/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php @@ -88,7 +88,7 @@ public function getByName(string $id = null): void $this->model->setName($data['id']); } else { throw new Model\Exception\NotFoundException(sprintf( - 'Thumbnail with ID "%s" does not exist.', + 'Import Definition with ID "%s" does not exist.', $this->model->getName() )); } diff --git a/src/DataDefinitionsBundle/ProcessManager/ExportDefinitionStartupFormResolver.php b/src/DataDefinitionsBundle/ProcessManager/ExportDefinitionStartupFormResolver.php index 44862384..83049a4d 100644 --- a/src/DataDefinitionsBundle/ProcessManager/ExportDefinitionStartupFormResolver.php +++ b/src/DataDefinitionsBundle/ProcessManager/ExportDefinitionStartupFormResolver.php @@ -16,7 +16,7 @@ namespace Instride\Bundle\DataDefinitionsBundle\ProcessManager; -use CoreShop\Component\Resource\Repository\RepositoryInterface; +use Instride\Bundle\DataDefinitionsBundle\Repository\DefinitionRepository; use ProcessManagerBundle\Model\ExecutableInterface; use ProcessManagerBundle\Process\ProcessStartupFormResolverInterface; use Instride\Bundle\DataDefinitionsBundle\Form\Type\ProcessManager\ExportDefinitionObjectStartupForm; @@ -24,11 +24,10 @@ final class ExportDefinitionStartupFormResolver implements ProcessStartupFormResolverInterface { - private $definitionRepository; - - public function __construct(RepositoryInterface $definitionRepository) + public function __construct( + private readonly DefinitionRepository $definitionRepository + ) { - $this->definitionRepository = $definitionRepository; } public function supports(ExecutableInterface $executable): bool @@ -37,7 +36,7 @@ public function supports(ExecutableInterface $executable): bool return false; } - $definition = $this->definitionRepository->find($executable->getSettings()['definition']); + $definition = $this->definitionRepository->findByName($executable->getSettings()['definition']); if (!$definition instanceof ExportDefinitionInterface) { return false; diff --git a/src/DataDefinitionsBundle/Provider/CsvProvider.php b/src/DataDefinitionsBundle/Provider/CsvProvider.php index 237b8507..2d6a3642 100644 --- a/src/DataDefinitionsBundle/Provider/CsvProvider.php +++ b/src/DataDefinitionsBundle/Provider/CsvProvider.php @@ -47,12 +47,13 @@ public function getColumns(array $configuration): array $enclosure = $configuration['enclosure']; $returnHeaders = []; - $rows = str_getcsv($csvHeaders ?: $csvExample, "\n"); //parse the rows + $csv = $csvHeaders ?: $csvExample; + $rows = str_getcsv($csv ?: '', "\n"); //parse the rows if (count($rows) > 0) { $headerRow = $rows[0]; - $headers = str_getcsv($headerRow, $delimiter ?? ',', $enclosure ?: chr(8)); + $headers = str_getcsv($headerRow ?: '', $delimiter ?? ',', $enclosure ?: chr(8)); if (count($headers) > 0) { //First line are the headers diff --git a/src/DataDefinitionsBundle/Repository/DefinitionRepository.php b/src/DataDefinitionsBundle/Repository/DefinitionRepository.php index 431f851c..c110f5f3 100644 --- a/src/DataDefinitionsBundle/Repository/DefinitionRepository.php +++ b/src/DataDefinitionsBundle/Repository/DefinitionRepository.php @@ -21,6 +21,11 @@ class DefinitionRepository extends PimcoreDaoRepository { + public function find($id) + { + return $this->findByName($id); + } + public function findByName(string $name): ?DataDefinitionInterface { $class = $this->metadata->getClass('model');