private function getSymfonyValidatorConstraints()
    {

        $constraints = array();

        $this->loadUnsettableProperties();

        foreach ( $this->dataTypes as $column => $type ) {

            // skip inherited columns
            if( $type->isInherited() ) {
                continue;
            }

            // Skip Columns designated unsetable.
            if( in_array( $column, $this->unsetableProperties ) ) {
                continue;
            }

            // Check if column is nullable.
            if( !$type->isNullable() and !$type->hasDefault() ){
                $constraints[] = $this->getSymfonyConstraint( $column, 'NotNull');
            }

            // Normality entity type constraints.
            if( $type->getEntity() === 'normality' ) {

                $dataType = $this->options['entityPlaceholder']."\\{$type->getNormality()}";
                $constraints[] = $this->getSymfonyTypeConstraint( $column, $dataType );

            } elseif( $type->getEntity() ){

                $dataType = "Bond\\Entity\\Types\\{$type->getEntity()}";
                $constraints[] = $this->getSymfonyTypeConstraint( $column, $dataType );

            } elseif( $type->isEnum( $enumName ) ) {

                $constraints[] = $this->getSymfonyChoiceConstraint(
                    $column,
                    $this->pgClass->getCatalog()->enum->getValues($enumName)
                );

            } else {

                switch( $type->getType() ) {

                    case 'int':

                        $constraints[] = $this->getSymfonyConstraint( $column, 'RealInt', null, false );
                        $this->class->addUses( 'Bond\\Bridge\\Normality\\Constraint\\RealInt' );
                        break;

                    case 'citext':
                    case 'text':

                        $constraints[] = $this->getSymfonyTypeConstraint( $column, 'string' );
                        if( is_numeric( $type->getLength() ) ) {
                            $constraints[] = $this->getSymfonyConstraint( $column, 'MaxLength', $type->getLength() );
                        }
                        break;

                    case 'bool':

                        $constraints[] = $this->getSymfonyTypeConstraint( $column, 'bool' );
                        break;

                }

            }

            $constraints[] = '';

        }

        return implode( "\n", $constraints );

    }
private function getSymfonyValidatorConstraints()
    {

        $constraints = array();

        $this->loadUnsettableProperties();

        foreach ( $this->dataTypes as $column => $type ) {

            // skip inherited columns
            if( $type->isInherited() ) {
                continue;
            }

            // Skip Columns designated unsetable.
            if( in_array( $column, $this->unsetableProperties ) ) {
                continue;
            }

            // Check if column is nullable.
            if( !$type->isNullable() and !$type->hasDefault() ){
                $constraints[] = $this->getSymfonyConstraint( $column, 'NotNull');
            }

            // Normality entity type constraints.
            if( $type->getEntity() === 'normality' ) {

                $dataType = $this->options['entityPlaceholder']."\\{$type->getNormality()}";
                $constraints[] = $this->getSymfonyTypeConstraint( $column, $dataType );

            } elseif( $type->getEntity() ){

                $dataType = "Bond\\Entity\\Types\\{$type->getEntity()}";
                $constraints[] = $this->getSymfonyTypeConstraint( $column, $dataType );

            } elseif( $type->isEnum( $enumName ) ) {

                $constraints[] = $this->getSymfonyChoiceConstraint(
                    $column,
                    $this->pgClass->getCatalog()->enum->getValues($enumName)
                );

            } else {

                switch( $type->getType() ) {

                    case 'int':

                        $constraints[] = $this->getSymfonyConstraint( $column, 'RealInt', null, false );
                        $this->class->addUses( 'Bond\\Bridge\\Normality\\Constraint\\RealInt' );
                        break;

                    case 'citext':
                    case 'text':

                        $constraints[] = $this->getSymfonyTypeConstraint( $column, 'string' );
                        if( is_numeric( $type->getLength() ) ) {
                            $constraints[] = $this->getSymfonyConstraint( $column, 'MaxLength', $type->getLength() );
                        }
                        break;

                    case 'bool':

                        $constraints[] = $this->getSymfonyTypeConstraint( $column, 'bool' );
                        break;

                }

            }

            $constraints[] = '';

        }

        return implode( "\n", $constraints );

    }
private function getSymfonyValidatorConstraints ( ) { $ constraints = array ( ) ; $ this -> loadUnsettableProperties ( ) ; foreach ( $ this -> dataTypes as $ column => $ type ) { // skip inherited columns if ( $ type -> isInherited ( ) ) { continue ; } // Skip Columns designated unsetable. if ( in_array ( $ column , $ this -> unsetableProperties ) ) { continue ; } // Check if column is nullable. if ( ! $ type -> isNullable ( ) and ! $ type -> hasDefault ( ) ) { $ constraints [ ] = $ this -> getSymfonyConstraint ( $ column , 'NotNull' ) ; } // Normality entity type constraints. if ( $ type -> getEntity ( ) === 'normality' ) { $ dataType = $ this -> options [ 'entityPlaceholder' ] . "\\{$type->getNormality()}" ; $ constraints [ ] = $ this -> getSymfonyTypeConstraint ( $ column , $ dataType ) ; } elseif ( $ type -> getEntity ( ) ) { $ dataType = "Bond\\Entity\\Types\\{$type->getEntity()}" ; $ constraints [ ] = $ this -> getSymfonyTypeConstraint ( $ column , $ dataType ) ; } elseif ( $ type -> isEnum ( $ enumName ) ) { $ constraints [ ] = $ this -> getSymfonyChoiceConstraint ( $ column , $ this -> pgClass -> getCatalog ( ) -> enum -> getValues ( $ enumName ) ) ; } else { switch ( $ type -> getType ( ) ) { case 'int' : $ constraints [ ] = $ this -> getSymfonyConstraint ( $ column , 'RealInt' , null , false ) ; $ this -> class -> addUses ( 'Bond\\Bridge\\Normality\\Constraint\\RealInt' ) ; break ; case 'citext' : case 'text' : $ constraints [ ] = $ this -> getSymfonyTypeConstraint ( $ column , 'string' ) ; if ( is_numeric ( $ type -> getLength ( ) ) ) { $ constraints [ ] = $ this -> getSymfonyConstraint ( $ column , 'MaxLength' , $ type -> getLength ( ) ) ; } break ; case 'bool' : $ constraints [ ] = $ this -> getSymfonyTypeConstraint ( $ column , 'bool' ) ; break ; } } $ constraints [ ] = '' ; } return implode ( "\n" , $ constraints ) ; }
Get Symfony validator contraints
@return string
Get Symfony validator contraints