Completed
Pull Request — master (#91)
by Piotr
02:36
created

PasswordResetBatchElement   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 46
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A apply() 0 7 1
A getId() 0 4 1
A getClassName() 0 4 1
1
<?php
2
3
namespace FSi\Bundle\AdminSecurityBundle\Doctrine\Admin;
4
5
use FSi\Bundle\AdminBundle\Doctrine\Admin\BatchElement;
6
use FSi\Bundle\AdminSecurityBundle\Event\AdminSecurityEvents;
7
use FSi\Bundle\AdminSecurityBundle\Event\ResetPasswordRequestEvent;
8
use FSi\Bundle\AdminSecurityBundle\Security\User\ResettablePasswordInterface;
9
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
10
11
class PasswordResetBatchElement extends BatchElement
12
{
13
    /**
14
     * @var string
15
     */
16
    private $userModel;
17
18
    /**
19
     * @var EventDispatcherInterface
20
     */
21
    private $eventDispatcher;
22
23
    public function __construct($options, $userModel, EventDispatcherInterface $eventDispatcher)
24
    {
25
        parent::__construct($options);
26
        $this->userModel = $userModel;
27
        $this->eventDispatcher = $eventDispatcher;
28
    }
29
30
    /**
31
     * @param ResettablePasswordInterface $object
32
     */
33
    public function apply($object)
34
    {
35
        $this->eventDispatcher->dispatch(
36
            AdminSecurityEvents::RESET_PASSWORD_REQUEST,
37
            new ResetPasswordRequestEvent($object)
38
        );
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getId()
45
    {
46
        return 'admin_security_password_reset';
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getClassName()
53
    {
54
        return $this->userModel;
55
    }
56
}
57