Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ec27afd323
Fetching contributors…

Cannot retrieve contributors at this time

62 lines (50 sloc) 2.119 kb
/**
* Validates the object and all objects related to this table.
*
* @see getValidationFailures()
* @param object $validator A Validator class instance
* @return boolean Whether all objects pass validation.
*/
public function validate(Validator $validator = null)
{
if (null === $validator) {
$validator = new Validator(new ClassMetadataFactory(new StaticMethodLoader()), new ConstraintValidatorFactory(), new DefaultTranslator());
}
$failureMap = new ConstraintViolationList();
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
<?php if ($hasForeignKeys) : ?>
// We call the validate method on the following object(s) if they
// were passed to this object by their corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
<?php foreach($aVarNames as $aVarName) : ?>
//If validate() method exists, the validate-behavior is configured for related object
if (method_exists($this-><?php echo $aVarName; ?>, 'validate')) {
if (!$this-><?php echo $aVarName; ?>->validate($validator)) {
$failureMap->addAll($this-><?php echo $aVarName; ?>->getValidationFailures());
}
}
<?php endforeach; ?>
<?php endif; ?>
$retval = $validator->validate($this);
if (count($retval) > 0) {
$failureMap->addAll($retval);
}
<?php foreach($collVarNames as $collVarName) : ?>
if (null !== $this-><?php echo $collVarName; ?>) {
foreach ($this-><?php echo $collVarName; ?> as $referrerFK) {
if (method_exists($referrerFK, 'validate')) {
if (!$referrerFK->validate($validator)) {
$failureMap->addAll($referrerFK->getValidationFailures());
}
}
}
}
<?php endforeach; ?>
$this->alreadyInValidation = false;
}
$this->validationFailures = $failureMap;
return (Boolean) (!(count($this->validationFailures) > 0));
}
Jump to Line
Something went wrong with that request. Please try again.