From 7e38c245de73175dee79a7fdd0551a03b99f19f1 Mon Sep 17 00:00:00 2001 From: fszenborn Date: Thu, 12 May 2022 13:37:38 +0200 Subject: [PATCH 1/3] Update for Pimcore X --- .../ClassificationstoreBundle.php | 2 +- .../Command/ClassificationstoreExportCommand.php | 6 ++++-- .../Command/ClassificationstoreImportCommand.php | 10 ++++++---- .../DependencyInjection/Configuration.php | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ClassificationstoreBundle/ClassificationstoreBundle.php b/src/ClassificationstoreBundle/ClassificationstoreBundle.php index 24345e2..666f403 100644 --- a/src/ClassificationstoreBundle/ClassificationstoreBundle.php +++ b/src/ClassificationstoreBundle/ClassificationstoreBundle.php @@ -24,7 +24,7 @@ class ClassificationstoreBundle extends AbstractPimcoreBundle */ public function getComposerPackageName(): string { - return 'divante/classificationstore'; + return 'divante-ltd/pimcore-classification-store-importer'; } /** diff --git a/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php b/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php index 8c4ea72..907526b 100644 --- a/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php +++ b/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php @@ -10,7 +10,7 @@ use Divante\ClassificationstoreBundle\Export\Exporter; use Pimcore\Model\Asset; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -19,7 +19,7 @@ * Class ClassificationstoreExportCommand * @package Divante\ClassificationstoreBundle\Command */ -class ClassificationstoreExportCommand extends ContainerAwareCommand +class ClassificationstoreExportCommand extends Command { /** * @inheritdoc @@ -66,6 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $file = $input->getOption('file'); file_put_contents($file, $csv); } + + return 0; } /** diff --git a/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php b/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php index 94a0c68..05f0e84 100644 --- a/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php +++ b/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php @@ -14,7 +14,7 @@ use Divante\ClassificationstoreBundle\Constants; use Divante\ClassificationstoreBundle\Import\Interfaces\ItemInterface; use Pimcore\Model\Asset; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -24,7 +24,7 @@ * Class ClassificationstoreImportCommand * @package Divante\ClassificationstoreBundle\Command */ -class ClassificationstoreImportCommand extends ContainerAwareCommand +class ClassificationstoreImportCommand extends Command { /** * @inheritdoc @@ -60,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $assetObj = Asset::getByPath($asset); if (!$assetObj instanceof Asset) { $output->writeln("Asset doesn't exist"); - return; + return 0; } $file = PIMCORE_ASSET_DIRECTORY . $assetObj->getFullPath(); } else { @@ -72,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!file_exists($file)) { $output->writeln("File " . $file . " doesn't exist"); - return; + return 0; } // for count only @@ -120,5 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($counter > $success) { $output->writeln('Failed: ' . ($counter - $success) . ' items.'); } + + return 0; } } diff --git a/src/ClassificationstoreBundle/DependencyInjection/Configuration.php b/src/ClassificationstoreBundle/DependencyInjection/Configuration.php index e5bab8b..dcf985a 100755 --- a/src/ClassificationstoreBundle/DependencyInjection/Configuration.php +++ b/src/ClassificationstoreBundle/DependencyInjection/Configuration.php @@ -22,8 +22,8 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('classificationstore'); + $treeBuilder = new TreeBuilder('classificationstore'); + //$rootNode = $treeBuilder->root('classificationstore'); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for From 3fbe947e374b1c113945f2bfd2d34cc5429215fb Mon Sep 17 00:00:00 2001 From: fszenborn Date: Thu, 12 May 2022 13:50:54 +0200 Subject: [PATCH 2/3] Update for Pimcore X 0.9.1 --- .../Command/ClassificationstoreExportCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php b/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php index 907526b..05f2fca 100644 --- a/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php +++ b/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php @@ -21,6 +21,12 @@ */ class ClassificationstoreExportCommand extends Command { + + public function __construct(Exporter $exporter) + { + $this->exporterService = $exporter; + parent::__construct(); + } /** * @inheritdoc */ @@ -52,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $store = $input->getOption('store'); /** @var Exporter $exporter */ - $exporter = $this->getContainer()->get(Exporter::class); + $exporter = $this->exporterService; $csv = $exporter->getCsv($delimiter, $enclosure, $store); From adc6793653c41ebd1a00877db3794875b93e4c86 Mon Sep 17 00:00:00 2001 From: fszenborn Date: Thu, 12 May 2022 13:57:11 +0200 Subject: [PATCH 3/3] Update for Pimcore X - 0.9.3 --- .../ClassificationstoreExportCommand.php | 7 ++----- .../ClassificationstoreImportCommand.php | 18 +++++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php b/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php index 05f2fca..edff80e 100644 --- a/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php +++ b/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php @@ -24,7 +24,7 @@ class ClassificationstoreExportCommand extends Command public function __construct(Exporter $exporter) { - $this->exporterService = $exporter; + $this->exporter = $exporter; parent::__construct(); } /** @@ -57,10 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $store = $input->getOption('store'); - /** @var Exporter $exporter */ - $exporter = $this->exporterService; - - $csv = $exporter->getCsv($delimiter, $enclosure, $store); + $csv = $this->exporter->getCsv($delimiter, $enclosure, $store); $asset = $input->getOption('asset'); diff --git a/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php b/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php index 05f0e84..b2359f0 100644 --- a/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php +++ b/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php @@ -19,6 +19,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Serializer\SerializerInterface; /** * Class ClassificationstoreImportCommand @@ -26,6 +27,13 @@ */ class ClassificationstoreImportCommand extends Command { + + public function __construct(Importer $importer, SerializerInterface $serializer) + { + $this->importer = $importer; + $this->serializer = $serializer; + parent::__construct(); + } /** * @inheritdoc */ @@ -77,8 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // for count only $csvData = file_get_contents($file); - $serializer = $this->getContainer()->get('serializer'); - $data = $serializer->decode($csvData, 'csv', ['csv_delimiter' => $delimiter, 'csv_enclosure' => $enclosure]); + $data = $this->serializer->decode($csvData, 'csv', ['csv_delimiter' => $delimiter, 'csv_enclosure' => $enclosure]); $count = count($data); $output->writeln('Importing `' . $count . '` lines.'); // for count only - end @@ -86,9 +93,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $progressBar = new ProgressBar($output, $count); $progressBar->start(); - /** @var Importer $importer */ - $importer = $this->getContainer()->get(Importer::class); - $file = new \SplFileObject($file); $file->setFlags(\SplFileObject::READ_CSV); $file->setCsvControl($delimiter, $enclosure); @@ -102,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $counter++; try { - $item = $importer->importItem($data); + $item = $this->importer->importItem($data); $success++; $output->writeln("imported: " . $item->getItemType() . " name: " . $item->getName()); } catch (\Exception $exception) { @@ -120,7 +124,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($counter > $success) { $output->writeln('Failed: ' . ($counter - $success) . ' items.'); } - + return 0; } }