Completed
Pull Request — develop (#165)
by Robbie
04:15
created

GenerateCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
rs 9.4286
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace N98\Magento\Command\GiftCard\Pool;
4
5
use N98\Magento\Command\GiftCard\AbstractGiftCardCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Magento\GiftCardAccount\Model\Pool;
11
12
class GenerateCommand extends AbstractGiftCardCommand
13
{
14
    /**
15
     * Setup
16
     * 
17
     * @return void
18
     */
19
    protected function configure()
20
    {
21
        $this
22
            ->setName('giftcard:pool:generate')
23
            ->setDescription('Generate a new gift card pool');
24
25
        $help = <<<HELP
26
Generate a new gift card pool
27
HELP;
28
        $this->setHelp($help);
29
    }
30
31
    /**
32
     * @param \Symfony\Component\Console\Input\InputInterface $input
33
     * @param \Symfony\Component\Console\Output\OutputInterface $output
34
     * @return void
35
     */
36
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38
        $this->detectMagento($output, true);
39
        if (!$this->initMagento()) {
40
            return;
41
        }
42
43
        $this->setAdminArea();
44
45
        try {
46
            $this
47
                ->getObjectManager()
48
                ->create(Pool::class)
49
                ->generatePool();
50
51
            $output->writeln('<info>Gift card pool was generated.</info>');
52
        } catch (\Exception $e) {
53
            $output->writeln('<error>Failed to generate gift card pool!</error>');
54
        }
55
    }
56
}
57