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

TrickEditedSubscriber::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\EventSubscriber\Trick;
4
5
use App\Event\Trick\TrickEditedEvent;
6
use App\Services\FlashMessageCategory;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
class TrickEditedSubscriber extends TrickSubscriber implements EventSubscriberInterface
10
{
11
    /**
12
     * Send trick to the database and set a flash message
13
     * @param TrickEditedEvent $event
14
     */
15
    public function updateTrickInDatabase(TrickEditedEvent $event)
16
    {
17
        $trick = $event->getEntity();
18
        $this->sendToDatabase($event);
19
        $this->addFlash(FlashMessageCategory::SUCCESS, 'Trick ' . $trick->getName() . ' updated');
20
    }
21
22
    /**
23
     * @return array The event names to listen to
24
     */
25
    public static function getSubscribedEvents()
26
    {
27
        return [
28
            TrickEditedEvent::NAME => 'updateTrickInDatabase'
29
        ];
30
    }
31
}