Passed
Branch feature/comments (12b220)
by Stone
04:53
created

CommentDeletedSubscriber::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
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\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
        /** @var Comment $comment */
19
        $comment = $event->getEntity();
0 ignored issues
show
Unused Code introduced by
The assignment to $comment is dead and can be removed.
Loading history...
20
        $this->deleteFromDatabase($event);
21
        $this->addFlash(FlashMessageCategory::SUCCESS, 'Comment Deleted');
22
    }
23
24
    /**
25
     * @return array The event names to listen to
26
     */
27
    public static function getSubscribedEvents()
28
    {
29
        return [
30
            CommentDeletedEvent::NAME => 'deleteCommentFromDatabase'
31
        ];
32
    }
33
}