/** * Validates the object and all objects related to this table. * * @see getValidationFailures() * @param ValidatorInterface|null $validator A Validator class instance * @return boolean Whether all objects pass validation. */ public function validate(ValidatorInterface $validator = null) { if (null === $validator) { $validator = new RecursiveValidator( new ExecutionContextFactory(new IdentityTranslator()), new LazyLoadingMetadataFactory(new StaticMethodLoader()), new ConstraintValidatorFactory() ); } $failureMap = new ConstraintViolationList(); if (!$this->alreadyInValidation) { $this->alreadyInValidation = true; $retval = null; $retval = $validator->validate($this); if (count($retval) > 0) { $failureMap->addAll($retval); } $this->alreadyInValidation = false; } $this->validationFailures = $failureMap; return (bool) (!(count($this->validationFailures) > 0)); }