Added constraints for selectable attribute.

This commit is contained in:
Jan Böhmer 2019-08-12 21:47:25 +02:00
parent 408d98c6e1
commit 51be176418
12 changed files with 169 additions and 0 deletions

View file

@ -37,6 +37,7 @@ use Symfony\Bundle\MakerBundle\Str;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
/**
* The validator for the NoneOfItsChildren annotation.
@ -62,6 +63,11 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
return;
}
//Check type of value. Validating only works for StructuralDBElements
if (!$value instanceof StructuralDBElement) {
throw new UnexpectedValueException($value, 'StructuralDBElement');
}
//Check if the object is assigned to itself
/** @var StructuralDBElement $entity */
$entity = $this->context->getObject();