src/Graviton/SchemaBundle/Constraint/ConstraintBuilder.php
public function addConstraints($fieldName, Schema $property, DocumentModel $model)
    {
        $constraints = $model->getConstraints($fieldName);

        if (!is_array($constraints)) {
            return $property;
        }

        foreach ($constraints as $constraint) {
            $isSupported = false;
            foreach ($this->builders as $builder) {
                if ($builder->supportsConstraint($constraint->name, $constraint->options)) {
                    $property = $builder->buildConstraint($fieldName, $property, $model, $constraint->options);
                    $isSupported = true;
                }
            }

            if (!$isSupported) {
                /**
                 * unknown/not supported constraints will be added to the 'x-constraints' schema property.
                 * this allows others (possibly schema constraints) to pick it up and implement more advanced logic.
                 */
                 $property->addConstraint($constraint->name);
            }
        }

        return $property;
    }
public function addConstraints($fieldName, Schema $property, DocumentModel $model)
    {
        $constraints = $model->getConstraints($fieldName);

        if (!is_array($constraints)) {
            return $property;
        }

        foreach ($constraints as $constraint) {
            $isSupported = false;
            foreach ($this->builders as $builder) {
                if ($builder->supportsConstraint($constraint->name, $constraint->options)) {
                    $property = $builder->buildConstraint($fieldName, $property, $model, $constraint->options);
                    $isSupported = true;
                }
            }

            if (!$isSupported) {
                /**
                 * unknown/not supported constraints will be added to the 'x-constraints' schema property.
                 * this allows others (possibly schema constraints) to pick it up and implement more advanced logic.
                 */
                 $property->addConstraint($constraint->name);
            }
        }

        return $property;
    }
public function addConstraints ( $ fieldName , Schema $ property , DocumentModel $ model ) { $ constraints = $ model -> getConstraints ( $ fieldName ) ; if ( ! is_array ( $ constraints ) ) { return $ property ; } foreach ( $ constraints as $ constraint ) { $ isSupported = false ; foreach ( $ this -> builders as $ builder ) { if ( $ builder -> supportsConstraint ( $ constraint -> name , $ constraint -> options ) ) { $ property = $ builder -> buildConstraint ( $ fieldName , $ property , $ model , $ constraint -> options ) ; $ isSupported = true ; } } if ( ! $ isSupported ) { /**
                 * unknown/not supported constraints will be added to the 'x-constraints' schema property.
                 * this allows others (possibly schema constraints) to pick it up and implement more advanced logic.
                 */ $ property -> addConstraint ( $ constraint -> name ) ; } } return $ property ; }
Go through the constraints and call the builders to do their job

@param string        $fieldName field name
@param Schema        $property  the property
@param DocumentModel $model     the parent model

@return Schema
Go through the constraints and call the builders to do their job