1 | <?php |
||
11 | class PasswordListener implements EventSubscriber |
||
12 | { |
||
13 | private $encoder; |
||
14 | |||
15 | 15 | public function __construct(UserPasswordEncoder $encoder) |
|
26 | 3 | public function prePersist(LifecycleEventArgs $args) |
|
27 | { |
||
28 | 3 | $entity = $args->getEntity(); |
|
29 | |||
30 | 3 | if ($entity instanceof UserInterface && $entity->getPlainPassword()) { |
|
31 | 1 | $this->encodePassword($entity); |
|
32 | } |
||
33 | 3 | } |
|
34 | 8 | public function preUpdate(PreUpdateEventArgs $args) |
|
35 | { |
||
36 | 8 | $entity = $args->getEntity(); |
|
37 | |||
38 | 8 | if ($entity instanceof UserInterface && $entity->getPlainPassword()) { |
|
39 | 2 | $this->encodePassword($entity); |
|
40 | } |
||
41 | 8 | } |
|
42 | 3 | private function encodePassword($entity) |
|
48 | } |
||
49 |