Test Setup Failed
Push — develop ( dc2cdb...883a72 )
by Stone
04:31
created

TrickCreatedSubscriber   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerTrickToDatabase() 0 5 1
A getSubscribedEvents() 0 4 1
1
<?php
2
3
namespace App\EventSubscriber\Trick;
4
5
use App\Event\Trick\TrickCreatedEvent;
6
use App\Services\FlashMessageCategory;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
class TrickCreatedSubscriber extends TrickSubscriber implements EventSubscriberInterface
10
{
11
    /**
12
     * Send trick to the database and set a flash message
13
     * @param TrickCreatedEvent $event
14
     */
15
    public function registerTrickToDatabase(TrickCreatedEvent $event)
16
    {
17
        $trick = $event->getEntity();
18
        $this->sendToDatabase($event);
19
        $this->addFlash(FlashMessageCategory::SUCCESS, 'Trick ' . $trick->getName() . ' created');
20
    }
21
22
    /**
23
     * @return array The event names to listen to
24
     */
25
    public static function getSubscribedEvents()
26
    {
27
        return [
28
            TrickCreatedEvent::NAME => 'registerTrickToDatabase'
29
        ];
30
    }
31
}