blob: 9e95eb47a9613d9ed0727a889b3b3925a8fa3d11 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
namespace Wallabag\CoreBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\ExecutionContextInterface;
use Doctrine\Bundle\DoctrineBundle\Registry;
class ForgotPasswordType extends AbstractType
{
private $doctrine = null;
public function __construct(Registry $doctrine)
{
$this->doctrine = $doctrine;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', 'email', array(
'required' => true,
'constraints' => array(
new Constraints\Email(),
new Constraints\NotBlank(),
new Constraints\Callback(array(array($this, 'validateEmail'))),
),
))
;
}
public function getName()
{
return 'forgot_password';
}
public function validateEmail($email, ExecutionContextInterface $context)
{
$user = $this->doctrine
->getRepository('WallabagCoreBundle:User')
->findOneByEmail($email);
if (!$user) {
$context->addViolationAt(
'email',
'No user found with this email',
array(),
$email
);
}
}
}
|