Scd16Command::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace TEiling\Scd16\Commands;
4
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputOption;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Shopware\Commands\ShopwareCommand;
10
use Symfony\Component\Console\Helper\ProgressBar;
11
use Shopware_Plugins_Core_Scd16_Container as Container;
12
13
class Scd16Command extends ShopwareCommand
14
{
15
    /**
16
     * {@inheritdoc}
17
     * @throws \InvalidArgumentException
18
     */
19
    protected function configure()
20
    {
21
        $this->setName('scd16:import:articles')
22
            ->setDescription('Import all Articles')
23
            ->addOption(
24
                'debug',
25
                null,
26
                InputOption::VALUE_NONE,
27
                'If set, more infos will be printed'
28
            );
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     * @throws \Exception
34
     * @throws \Symfony\Component\DependencyInjection\Exception\BadMethodCallException
35
     * @throws \Zend_Cache_Exception
36
     */
37
    protected function execute(InputInterface $input, OutputInterface $output)
38
    {
39
        if ($input->getOption('debug')) {
40
            error_reporting(E_ALL);
41
        } else {
42
            error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
43
        }
44
45
        $progress = new ProgressBar($output);
46
        $progress->start();
47
48
        $container = new Container();
49
        $path = Shopware()->Plugins()->Core()->Scd16()->Path() . '/tests/fixtures/shopexport_short.csv';
50
        $articleImporter = $container->get('teiling.scd16.importer.article_importer');
51
52
        $status = $articleImporter->importArticles($path, $progress);
53
        $progress->finish();
54
        $output->write("\n");
55
        $output->writeln('updated: ' . $status['updated']);
56
        $output->writeln('created: ' . $status['created']);
57
        $output->writeln('errors: ' . $status['errors']);
58
        $output->write("\n");
59
    }
60
}
61