Symfony\Component\Validator\Constraint::getTargets PHP Method

getTargets() public method

This method should return one or more of the constants Constraint::CLASS_CONSTRAINT and Constraint::PROPERTY_CONSTRAINT.
public getTargets ( ) : string | array
return string | array One or more constant values
    public function getTargets()
    {
        return self::PROPERTY_CONSTRAINT;
    }

Usage Example

 /**
  * {@inheritDoc}
  */
 public function addConstraint(Constraint $constraint)
 {
     if (!in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) {
         throw new ConstraintDefinitionException(sprintf('The constraint %s cannot be put on classes', get_class($constraint)));
     }
     $constraint->addImplicitGroupName($this->getDefaultGroup());
     parent::addConstraint($constraint);
 }
All Usage Examples Of Symfony\Component\Validator\Constraint::getTargets