UserValidatedSubscriber::sendFlash()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\EventSubscriber\User;
4
5
use App\Entity\User;
6
use App\Event\User\UserValidatedEvent;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
class UserValidatedSubscriber extends AbstractUserSubscriber implements EventSubscriberInterface
10
{
11
12
13
    public function validateUser(UserValidatedEvent $event)
14
    {
15
        /** @var User $user */
16
        $user = $event->getEntity();
17
        $user->setVerified(true);
18
        $this->persist($event);
19
    }
20
21
    public function sendFlash()
22
    {
23
        $this->addFlashMessage('success', 'Account is verified');
24
    }
25
26
27
    /**
28
     * @return array The event names to listen to
29
     */
30
    public static function getSubscribedEvents()
31
    {
32
        return [
33
            UserValidatedEvent::NAME => [
34
                ['validateUser', 40],
35
                ['flush', 20],
36
                ['sendFlash', 0],
37
            ]
38
        ];
39
    }
40
}