diff --git a/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php b/src/ClassificationstoreBundle/Command/ClassificationstoreExportCommand.php
index 8c4ea72..edff80e 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,8 +19,14 @@
* Class ClassificationstoreExportCommand
* @package Divante\ClassificationstoreBundle\Command
*/
-class ClassificationstoreExportCommand extends ContainerAwareCommand
+class ClassificationstoreExportCommand extends Command
{
+
+ public function __construct(Exporter $exporter)
+ {
+ $this->exporter = $exporter;
+ parent::__construct();
+ }
/**
* @inheritdoc
*/
@@ -51,10 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$store = $input->getOption('store');
- /** @var Exporter $exporter */
- $exporter = $this->getContainer()->get(Exporter::class);
-
- $csv = $exporter->getCsv($delimiter, $enclosure, $store);
+ $csv = $this->exporter->getCsv($delimiter, $enclosure, $store);
$asset = $input->getOption('asset');
@@ -66,6 +69,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..b2359f0 100644
--- a/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php
+++ b/src/ClassificationstoreBundle/Command/ClassificationstoreImportCommand.php
@@ -14,18 +14,26 @@
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;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Serializer\SerializerInterface;
/**
* Class ClassificationstoreImportCommand
* @package Divante\ClassificationstoreBundle\Command
*/
-class ClassificationstoreImportCommand extends ContainerAwareCommand
+class ClassificationstoreImportCommand extends Command
{
+
+ public function __construct(Importer $importer, SerializerInterface $serializer)
+ {
+ $this->importer = $importer;
+ $this->serializer = $serializer;
+ parent::__construct();
+ }
/**
* @inheritdoc
*/
@@ -60,7 +68,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,13 +80,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!file_exists($file)) {
$output->writeln("File " . $file . " doesn't exist");
- return;
+ return 0;
}
// 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,5 +124,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