protected function getDocumentBody( array $document )
    {
        if ( strpos( $document['Content-Type'], 'application/json' ) === 0 )
        {
            $source = json_decode( $document['body'], true );
            unset( $source['_rev'] );
            return json_encode( $source );
        }

        if ( is_array( $document['body'] ) )
        {
            $main   = array_shift( $document['body'] );
            $source = json_decode( $main['body'], true );
            unset( $source['_rev'] );

            $source['_attachments'] = array();
            foreach ( $document['body'] as $attachment )
            {
                $source['_attachments'][$attachment['Content-ID']] = array(
                    'content_type' => $attachment['Content-Type'],
                    'data'         => base64_encode( $attachment['body'] ),
                );
            }

            return json_encode( $source );
        }

        throw new phpillowMultipartParserException( "Invalid document: " . var_export( $document, true ) );
    }
protected function getDocumentBody( array $document )
    {
        if ( strpos( $document['Content-Type'], 'application/json' ) === 0 )
        {
            $source = json_decode( $document['body'], true );
            unset( $source['_rev'] );
            return json_encode( $source );
        }

        if ( is_array( $document['body'] ) )
        {
            $main   = array_shift( $document['body'] );
            $source = json_decode( $main['body'], true );
            unset( $source['_rev'] );

            $source['_attachments'] = array();
            foreach ( $document['body'] as $attachment )
            {
                $source['_attachments'][$attachment['Content-ID']] = array(
                    'content_type' => $attachment['Content-Type'],
                    'data'         => base64_encode( $attachment['body'] ),
                );
            }

            return json_encode( $source );
        }

        throw new phpillowMultipartParserException( "Invalid document: " . var_export( $document, true ) );
    }
protected function getDocumentBody ( array $ document ) { if ( strpos ( $ document [ 'Content-Type' ] , 'application/json' ) === 0 ) { $ source = json_decode ( $ document [ 'body' ] , true ) ; unset ( $ source [ '_rev' ] ) ; return json_encode ( $ source ) ; } if ( is_array ( $ document [ 'body' ] ) ) { $ main = array_shift ( $ document [ 'body' ] ) ; $ source = json_decode ( $ main [ 'body' ] , true ) ; unset ( $ source [ '_rev' ] ) ; $ source [ '_attachments' ] = array ( ) ; foreach ( $ document [ 'body' ] as $ attachment ) { $ source [ '_attachments' ] [ $ attachment [ 'Content-ID' ] ] = array ( 'content_type' => $ attachment [ 'Content-Type' ] , 'data' => base64_encode ( $ attachment [ 'body' ] ) , ) ; } return json_encode ( $ source ) ; } throw new phpillowMultipartParserException ( "Invalid document: " . var_export ( $ document , true ) ) ; }
Clean up document definition

Returns the cleaned up document body as a result.

@param array $document
@return string
Clean up document definition