Test Failed
Branch feature/comments (9f6e99)
by Stone
08:48
created

CommentCreatedSubscriber::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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