Completed
Pull Request — master (#50)
by De Cramer
03:11
created

SymfonyEventAdapter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace eXpansion\Framework\Core\Services;
4
5
use eXpansion\Framework\Core\Model\Event\DedicatedEvent;
6
use eXpansion\Framework\Core\Services\Application\DispatcherInterface;
7
use eXpansion\Framework\Core\Services\Application\EventProcessorInterface;
8
use eXpansion\Framework\Core\Storage\GameDataStorage;
9
use Maniaplanet\DedicatedServer\Connection;
10
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
11
12
/**
13
 * Class StorageProvider
14
 *
15
 * @author    de Cramer Oliver<[email protected]>
16
 * @copyright 2017 Smile
17
 * @package eXpansion\Framework\Core\Services
18
 */
19
class SymfonyEventAdapter implements EventProcessorInterface
20
{
21
    /** @var EventDispatcherInterface */
22
    protected $symfonyEventDispatcher;
23
24
25
    /**
26
     * StorageProvider constructor.
27
     *
28
     * @param $connection
29
     */
30 41
    public function __construct(
31
        EventDispatcherInterface $eventDispatcher
32
    ) {
33 41
        $this->symfonyEventDispatcher = $eventDispatcher;
34 41
    }
35
36
37
    /**
38
     * Dispatch event as it needs to be.
39
     *
40
     * @param string $eventName Name of the event.
41
     * @param array $params Parameters
42
     */
43 24
    public function dispatch($eventName, $params)
44
    {
45
46 24
        $event = new DedicatedEvent();
47 24
        $event->setParameters($params);
48 24
        $this->symfonyEventDispatcher->dispatch("maniaplanet.game." . $eventName, $event);
49
    }
50
}