|
1
|
|
|
<?php |
|
2
|
|
|
namespace VideoGamesRecords\CoreBundle\EventSubscriber; |
|
3
|
|
|
|
|
4
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
|
5
|
|
|
use VideoGamesRecords\CoreBundle\Event\GameEvent; |
|
6
|
|
|
use VideoGamesRecords\CoreBundle\Service\Badge\PlayerMasterBadgeHandler; |
|
7
|
|
|
use VideoGamesRecords\CoreBundle\Service\Badge\TeamMasterBadgeHandler; |
|
8
|
|
|
use VideoGamesRecords\CoreBundle\Service\GameManager; |
|
9
|
|
|
use VideoGamesRecords\CoreBundle\VideoGamesRecordsCoreEvents; |
|
10
|
|
|
|
|
11
|
|
|
final class GameSubscriber implements EventSubscriberInterface |
|
12
|
|
|
{ |
|
13
|
|
|
private PlayerMasterBadgeHandler $playerMasterBadgeHandler; |
|
14
|
|
|
private TeamMasterBadgeHandler $teamMasterBadgeHandler; |
|
15
|
|
|
private GameManager $gameManager; |
|
16
|
|
|
|
|
17
|
|
|
public function __construct( |
|
18
|
|
|
PlayerMasterBadgeHandler $playerMasterBadgeHandler, |
|
19
|
|
|
TeamMasterBadgeHandler $teamMasterBadgeHandler, |
|
20
|
|
|
GameManager $gameManager |
|
21
|
|
|
) { |
|
22
|
|
|
$this->playerMasterBadgeHandler = $playerMasterBadgeHandler; |
|
23
|
|
|
$this->teamMasterBadgeHandler = $teamMasterBadgeHandler; |
|
24
|
|
|
$this->gameManager = $gameManager; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public static function getSubscribedEvents(): array |
|
28
|
|
|
{ |
|
29
|
|
|
return [ |
|
30
|
|
|
VideoGamesRecordsCoreEvents::PLAYER_GAME_MAJ_COMPLETED => 'playerGamePostMaj', |
|
31
|
|
|
VideoGamesRecordsCoreEvents::TEAM_GAME_MAJ_COMPLETED => 'teamGamePostMaj', |
|
32
|
|
|
VideoGamesRecordsCoreEvents::SCORE_PLATFORM_UPDATED => 'majGame', |
|
33
|
|
|
]; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param GameEvent $event |
|
38
|
|
|
*/ |
|
39
|
|
|
public function playerGamePostMaj(GameEvent $event) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->playerMasterBadgeHandler->process($event->getGame()); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param GameEvent $event |
|
46
|
|
|
*/ |
|
47
|
|
|
public function teamGamePostMaj(GameEvent $event) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->teamMasterBadgeHandler->process($event->getGame()); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param GameEvent $event |
|
54
|
|
|
*/ |
|
55
|
|
|
public function majGame(GameEvent $event) |
|
56
|
|
|
{ |
|
57
|
|
|
$this->gameManager->maj($event->getGame()); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|