public static function makeFromAttribute( PgAttribute $attribute )
    {

        $name = $attribute->name;
        $entity = $attribute->getRelation()->getEntityName();
        $type = $attribute->getType();
        $fullyQualifiedName = $attribute->getFullyQualifiedName();

        $data = array(
            'isPrimaryKey' => $attribute->isPrimaryKey(),
            'isUnique' => $attribute->isUnique(),
            'isNullable' => !$attribute->notNull,
            'isArray' => $attribute->isArray,
            'isInherited' => $attribute->isInherited(),
            'type' => $type->getTypeQuery(),
            'length' => $attribute->length,
            'default' => $attribute->default,
        );

        $data += $attribute->getEntity();

        if( $type->isBool() and in_array( strtolower( $data['default'] ), array( 'true', 'false' ) ) ) {
            $data['default'] = \Bond\boolval( $data['default'] );
        }

        if( $type->isEnum() ) {
            $data['enumName'] = $type->name;
        }

        if( $tags = \Bond\extract_tags( $attribute->comment, 'form' ) ) {
            $data['form'] = $tags;
        }

        if( $tags = \Bond\extract_tags( $attribute->comment, 'api' ) ) {
            $data+= $tags;
        }

        if( $tags = \Bond\extract_tags( $attribute->comment, 'filter' ) ) {
            $data['filter'] = $tags;
        }

        if( $tags = \Bond\extract_tags( $attribute->comment, 'normality' ) ) {
            $data['isFormChoiceText'] = isset( $tags['form-choicetext'] );
            $data['isAutoComplete'] = isset( $tags['autoComplete'] );
        }

        return new static( $name, $entity, $fullyQualifiedName, $data );

    }
public static function makeFromAttribute( PgAttribute $attribute )
    {

        $name = $attribute->name;
        $entity = $attribute->getRelation()->getEntityName();
        $type = $attribute->getType();
        $fullyQualifiedName = $attribute->getFullyQualifiedName();

        $data = array(
            'isPrimaryKey' => $attribute->isPrimaryKey(),
            'isUnique' => $attribute->isUnique(),
            'isNullable' => !$attribute->notNull,
            'isArray' => $attribute->isArray,
            'isInherited' => $attribute->isInherited(),
            'type' => $type->getTypeQuery(),
            'length' => $attribute->length,
            'default' => $attribute->default,
        );

        $data += $attribute->getEntity();

        if( $type->isBool() and in_array( strtolower( $data['default'] ), array( 'true', 'false' ) ) ) {
            $data['default'] = \Bond\boolval( $data['default'] );
        }

        if( $type->isEnum() ) {
            $data['enumName'] = $type->name;
        }

        if( $tags = \Bond\extract_tags( $attribute->comment, 'form' ) ) {
            $data['form'] = $tags;
        }

        if( $tags = \Bond\extract_tags( $attribute->comment, 'api' ) ) {
            $data+= $tags;
        }

        if( $tags = \Bond\extract_tags( $attribute->comment, 'filter' ) ) {
            $data['filter'] = $tags;
        }

        if( $tags = \Bond\extract_tags( $attribute->comment, 'normality' ) ) {
            $data['isFormChoiceText'] = isset( $tags['form-choicetext'] );
            $data['isAutoComplete'] = isset( $tags['autoComplete'] );
        }

        return new static( $name, $entity, $fullyQualifiedName, $data );

    }
public static function makeFromAttribute ( PgAttribute $ attribute ) { $ name = $ attribute -> name ; $ entity = $ attribute -> getRelation ( ) -> getEntityName ( ) ; $ type = $ attribute -> getType ( ) ; $ fullyQualifiedName = $ attribute -> getFullyQualifiedName ( ) ; $ data = array ( 'isPrimaryKey' => $ attribute -> isPrimaryKey ( ) , 'isUnique' => $ attribute -> isUnique ( ) , 'isNullable' => ! $ attribute -> notNull , 'isArray' => $ attribute -> isArray , 'isInherited' => $ attribute -> isInherited ( ) , 'type' => $ type -> getTypeQuery ( ) , 'length' => $ attribute -> length , 'default' => $ attribute -> default , ) ; $ data += $ attribute -> getEntity ( ) ; if ( $ type -> isBool ( ) and in_array ( strtolower ( $ data [ 'default' ] ) , array ( 'true' , 'false' ) ) ) { $ data [ 'default' ] = \ Bond \ boolval ( $ data [ 'default' ] ) ; } if ( $ type -> isEnum ( ) ) { $ data [ 'enumName' ] = $ type -> name ; } if ( $ tags = \ Bond \ extract_tags ( $ attribute -> comment , 'form' ) ) { $ data [ 'form' ] = $ tags ; } if ( $ tags = \ Bond \ extract_tags ( $ attribute -> comment , 'api' ) ) { $ data += $ tags ; } if ( $ tags = \ Bond \ extract_tags ( $ attribute -> comment , 'filter' ) ) { $ data [ 'filter' ] = $ tags ; } if ( $ tags = \ Bond \ extract_tags ( $ attribute -> comment , 'normality' ) ) { $ data [ 'isFormChoiceText' ] = isset ( $ tags [ 'form-choicetext' ] ) ; $ data [ 'isAutoComplete' ] = isset ( $ tags [ 'autoComplete' ] ) ; } return new static ( $ name , $ entity , $ fullyQualifiedName , $ data ) ; }
Generate a dataType from a Bond\Pg\Catalog\PgAttribute
@param Attribute $attribute
@return static
Generate a dataType from a Bond \ Pg \ Catalog \ PgAttribute