|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\VoteManager\ChatCommand; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use eXpansion\Bundle\VoteManager\Services\VoteService; |
|
7
|
|
|
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups; |
|
8
|
|
|
use eXpansion\Framework\AdminGroups\Model\AbstractAdminChatCommand; |
|
9
|
|
|
use eXpansion\Framework\Core\Helpers\ChatNotification; |
|
10
|
|
|
use eXpansion\Framework\Core\Storage\PlayerStorage; |
|
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class Records |
|
15
|
|
|
* |
|
16
|
|
|
* @package eXpansion\Bundle\LocalRecords\ChatCommand; |
|
17
|
|
|
* @author reaby |
|
18
|
|
|
*/ |
|
19
|
|
|
class VotePass extends AbstractAdminChatCommand |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
/** @var VoteService */ |
|
23
|
|
|
private $voteService; |
|
24
|
|
|
|
|
25
|
|
|
/** @var PlayerStorage */ |
|
26
|
|
|
private $playerStorage; |
|
27
|
|
|
/** |
|
28
|
|
|
* @var ChatNotification |
|
29
|
|
|
*/ |
|
30
|
|
|
private $chatNotification; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* VoteStart constructor. |
|
34
|
|
|
* |
|
35
|
|
|
* @param $command |
|
36
|
|
|
* @param array $aliases |
|
37
|
|
|
* @param AdminGroups $adminGroups |
|
38
|
|
|
* @param VoteService $voteService |
|
39
|
|
|
* @param PlayerStorage $playerStorage |
|
40
|
|
|
* @param ChatNotification $chatNotification |
|
41
|
|
|
*/ |
|
42
|
|
View Code Duplication |
public function __construct( |
|
|
|
|
|
|
43
|
|
|
$command, |
|
44
|
|
|
$permission, |
|
45
|
|
|
array $aliases = [], |
|
46
|
|
|
AdminGroups $adminGroups, |
|
47
|
|
|
VoteService $voteService, |
|
48
|
|
|
PlayerStorage $playerStorage, |
|
49
|
|
|
ChatNotification $chatNotification |
|
50
|
|
|
) { |
|
51
|
|
|
parent::__construct($command, $permission, $aliases, $adminGroups); |
|
52
|
|
|
$this->voteService = $voteService; |
|
53
|
|
|
$this->playerStorage = $playerStorage; |
|
54
|
|
|
$this->chatNotification = $chatNotification; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @inheritdoc |
|
59
|
|
|
*/ |
|
60
|
|
|
public function execute($login, InputInterface $input) |
|
61
|
|
|
{ |
|
62
|
|
|
|
|
63
|
|
|
$level = $this->adminGroupsHelper->getLoginGroupLabel($login); |
|
64
|
|
|
$admin = $this->playerStorage->getPlayerInfo($login)->getNickName(); |
|
65
|
|
|
$this->chatNotification->sendMessage('expansion_votemanager.chat.admin_pass', null, ["%level%" => $level, "%admin%" |
|
66
|
|
|
=> $admin]); |
|
67
|
|
|
$this->voteService->pass(); |
|
68
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.