1
從約束得到的EntityManager
的事情是,我創建一個自定義的驗證,並在我的新的驗證器類,我應該做這樣的事情:有此錯誤在symfony中
class EmailDoesntExistValidator extends ConstraintAValidator
{
public function validate($value, Constraint $constraint)
{
$em = $this->getDoctrine()->getEntityManager(); // ERROR!!!!!!!
$result = $em->getRepository('CgboardSignupBundle:User')->userExist($value);
if (empty($result)) {
return true;
}
$this->context->addViolation($constraint->message, array());
return false;
}
}
林:
Error: Call to undefined method Cgboard\SignupBundle\Validator\Constraints\EmailDoesntExistValidator::getDoctrine()
有什麼想法?