TrickDeletedSubscriber::getSubscribedEvents()   A
last analyzed

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\TrickDeletedEvent;
6
use App\FlashMessage\FlashMessageCategory;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
class TrickDeletedSubscriber extends AbstractTrickSubscriber implements EventSubscriberInterface
10
{
11
    /**
12
     * Send trick to the database and set a flash message
13
     * @param TrickDeletedEvent $event
14
     */
15
    public function deleteTrickFromDatabase(TrickDeletedEvent $event)
16
    {
17
        $trick = $event->getEntity();
18
        $this->deleteFromDatabase($event);
19
        $this->addFlashMessage(FlashMessageCategory::SUCCESS, 'Trick ' . $trick->getName() . ' Deleted');
20
    }
21
22
    /**
23
     * @return array The event names to listen to
24
     */
25
    public static function getSubscribedEvents()
26
    {
27
        return [
28
            TrickDeletedEvent::NAME => 'deleteTrickFromDatabase'
29
        ];
30
    }
31
}