Completed
Pull Request — master (#104)
by
unknown
03:28
created

Add::setMxPlugin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace eXpansion\Bundle\Maps\ChatCommand;
4
5
use eXpansion\Bundle\AdminChat\ChatCommand\AbstractConnectionCommand;
6
use eXpansion\Bundle\Maps\Plugins\ManiaExchange;
7
use eXpansion\Bundle\Maps\Services\JukeboxService;
8
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Tests\eXpansion\Framework\AdminGroups\TestHelpers\AdminChatCommand;
12
13
/**
14
 *
15
 * @author  Reaby
16
 *
17
 */
18
class Add extends AdminChatCommand
19
{
20
21
    /** @var  ManiaExchange */
22
    protected $plugin;
23
24
    public function __construct(
25
        $command,
26
        $permission,
27
        $aliases = [],
28
        AdminGroups $adminGroupsHelper,
29
        ManiaExchange $plugin
30
    ) {
31
        parent::__construct($command, $permission, $aliases, $adminGroupsHelper);
32
        $this->plugin = $plugin;
33
    }
34
35
36
    public function getDescription()
37
    {
38
        return 'expansion_mx.command.add.help';
39
    }
40
41
    protected function configure()
42
    {
43
        parent::configure();
44
45
        $this->inputDefinition->addArgument(
46
            new InputArgument('mxid', InputArgument::REQUIRED, 'expansion_mx.command.add.mxid')
47
        );
48
49
        $this->inputDefinition->addArgument(
50
            new InputArgument('site', InputArgument::OPTIONAL, 'expansion_mx.command.add.site')
51
        );
52
53
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function execute($login, InputInterface $input)
60
    {
61
        $site = $input->getArgument('site');
62
        if (!$input->getArgument('site')) {
63
            $site = null;
64
        }
65
66
        $id = $input->getArgument('mxid');
67
68
        $this->plugin->addMap($login, $id, $site);
69
    }
70
71
    public function setMxPlugin(ManiaExchange $plugin)
72
    {
73
        $this->plugin = $plugin;
74
    }
75
}
76
77
78