public function convertFromTypeDefinition(TypeDefinitionInterface $typeDefinition)
    {
        $propertyList = [
            'baseTypeId' => JSONConstants::JSON_TYPE_BASE_ID,
            'parentTypeId' => JSONConstants::JSON_TYPE_PARENT_ID
        ];

        if ($typeDefinition instanceof RelationshipTypeDefinitionInterface) {
            $propertyList['allowedTargetTypeIds'] = JSONConstants::JSON_TYPE_ALLOWED_TARGET_TYPES;
            $propertyList['allowedSourceTypeIds'] = JSONConstants::JSON_TYPE_ALLOWED_SOURCE_TYPES;
        }

        $data = $typeDefinition->exportGettableProperties(
            $propertyList
        );
        $data = $this->castArrayValuesToSimpleTypes($data);

        return json_encode($data, JSON_FORCE_OBJECT);
    }
public function convertFromTypeDefinition(TypeDefinitionInterface $typeDefinition)
    {
        $propertyList = [
            'baseTypeId' => JSONConstants::JSON_TYPE_BASE_ID,
            'parentTypeId' => JSONConstants::JSON_TYPE_PARENT_ID
        ];

        if ($typeDefinition instanceof RelationshipTypeDefinitionInterface) {
            $propertyList['allowedTargetTypeIds'] = JSONConstants::JSON_TYPE_ALLOWED_TARGET_TYPES;
            $propertyList['allowedSourceTypeIds'] = JSONConstants::JSON_TYPE_ALLOWED_SOURCE_TYPES;
        }

        $data = $typeDefinition->exportGettableProperties(
            $propertyList
        );
        $data = $this->castArrayValuesToSimpleTypes($data);

        return json_encode($data, JSON_FORCE_OBJECT);
    }
public function convertFromTypeDefinition ( TypeDefinitionInterface $ typeDefinition ) { $ propertyList = [ 'baseTypeId' => JSONConstants :: JSON_TYPE_BASE_ID , 'parentTypeId' => JSONConstants :: JSON_TYPE_PARENT_ID ] ; if ( $ typeDefinition instanceof RelationshipTypeDefinitionInterface ) { $ propertyList [ 'allowedTargetTypeIds' ] = JSONConstants :: JSON_TYPE_ALLOWED_TARGET_TYPES ; $ propertyList [ 'allowedSourceTypeIds' ] = JSONConstants :: JSON_TYPE_ALLOWED_SOURCE_TYPES ; } $ data = $ typeDefinition -> exportGettableProperties ( $ propertyList ) ; $ data = $ this -> castArrayValuesToSimpleTypes ( $ data ) ; return json_encode ( $ data , JSON_FORCE_OBJECT ) ; }
Convert a type definition object to a custom format

@param TypeDefinitionInterface $typeDefinition
@return string JSON representation of the type definition
Convert a type definition object to a custom format