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

PasswordResetBatchElement::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
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