Passed
Push — develop ( 34195e...b04746 )
by Stone
08:36 queued 03:47
created

CommentDeletedSubscriber   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteCommentFromDatabase() 0 4 1
A getSubscribedEvents() 0 4 1
1
<?php
2
3
namespace App\EventSubscriber\Comment;
4
5
use App\Entity\Comment;
6
use App\Event\Comment\CommentDeletedEvent;
7
use App\FlashMessage\FlashMessageCategory;
8
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
9
10
class CommentDeletedSubscriber extends CommentSubscriber implements EventSubscriberInterface
11
{
12
    /**
13
     * Deletes a comment
14
     * @param CommentDeletedEvent $event
15
     */
16
    public function deleteCommentFromDatabase(CommentDeletedEvent $event)
17
    {
18
        $this->deleteFromDatabase($event);
19
        $this->addFlash(FlashMessageCategory::SUCCESS, 'Comment Deleted');
20
    }
21
22
    /**
23
     * @return array The event names to listen to
24
     */
25
    public static function getSubscribedEvents()
26
    {
27
        return [
28
            CommentDeletedEvent::NAME => 'deleteCommentFromDatabase'
29
        ];
30
    }
31
}