3 namespace Wallabag\CoreBundle\Form\Type
;
5 use Symfony\Component\Form\AbstractType
;
6 use Symfony\Component\Form\FormBuilderInterface
;
7 use Symfony\Component\Validator\Constraints
;
8 use Symfony\Component\Validator\ExecutionContextInterface
;
9 use Doctrine\Bundle\DoctrineBundle\Registry
;
11 class ForgotPasswordType
extends AbstractType
13 private $doctrine = null;
15 public function __construct(Registry
$doctrine)
17 $this->doctrine
= $doctrine;
20 public function buildForm(FormBuilderInterface
$builder, array $options)
23 ->add('email', 'email', array(
25 'constraints' => array(
26 new Constraints\
Email(),
27 new Constraints\
NotBlank(),
28 new Constraints\
Callback(array(array($this, 'validateEmail'))),
34 public function getName()
36 return 'forgot_password';
39 public function validateEmail($email, ExecutionContextInterface
$context)
41 $user = $this->doctrine
42 ->getRepository('WallabagCoreBundle:User')
43 ->findOneByEmail($email);
46 $context->addViolationAt(
48 'No user found with this email',