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(
24 'constraints' => array(
25 new Constraints\
Email(),
26 new Constraints\
NotBlank(),
27 new Constraints\
Callback(array(array($this, 'validateEmail'))),
33 public function getName()
35 return 'forgot_password';
38 public function validateEmail($email, ExecutionContextInterface
$context)
40 $user = $this->doctrine
41 ->getRepository('WallabagCoreBundle:User')
42 ->findOneByEmail($email);
45 $context->addViolationAt(
47 'No user found with this email',