public function constructMultipartOptions(array $data, array $multipart_data): array
    {
        $builder = new Builder();
        $this->logger->debug('Creating multi-part form array data (complex and expensive)');
        foreach ($data as $id => $value) {
              if (array_key_exists($id,$multipart_data)) {
                $data = new MultipartData(
                    (string) $multipart_data[$id]['id'],
                    stream_get_contents($multipart_data[$id]['stream']),
                    pathinfo($multipart_data[$id]['filename'], PATHINFO_BASENAME)
                );
                $builder->append($data);
            } elseif($id=='mediagroup') {
               foreach($multipart_data as $ii => $mdata){
                $data = new MultipartData(
                    pathinfo($mdata['filename'], PATHINFO_BASENAME),
                    stream_get_contents($mdata['stream']),
                    pathinfo($mdata['filename'], PATHINFO_BASENAME)
                );
                $builder->append($data);
               }
            } else {
                $data = new MultipartData((string) $id, (string) $value);
                $builder->append($data);
            }
        }

        $body = $builder->buildAll();
        $array = [
            'headers' => [
                'Content-Type' => 'multipart/form-data; boundary="' . $builder->getBoundary() . '"',
                'Content-Length' => \strlen($body)
            ],
            'body' => $body
        ];
        return $array;
    }
public function constructMultipartOptions(array $data, array $multipart_data): array
    {
        $builder = new Builder();
        $this->logger->debug('Creating multi-part form array data (complex and expensive)');
        foreach ($data as $id => $value) {
              if (array_key_exists($id,$multipart_data)) {
                $data = new MultipartData(
                    (string) $multipart_data[$id]['id'],
                    stream_get_contents($multipart_data[$id]['stream']),
                    pathinfo($multipart_data[$id]['filename'], PATHINFO_BASENAME)
                );
                $builder->append($data);
            } elseif($id=='mediagroup') {
               foreach($multipart_data as $ii => $mdata){
                $data = new MultipartData(
                    pathinfo($mdata['filename'], PATHINFO_BASENAME),
                    stream_get_contents($mdata['stream']),
                    pathinfo($mdata['filename'], PATHINFO_BASENAME)
                );
                $builder->append($data);
               }
            } else {
                $data = new MultipartData((string) $id, (string) $value);
                $builder->append($data);
            }
        }

        $body = $builder->buildAll();
        $array = [
            'headers' => [
                'Content-Type' => 'multipart/form-data; boundary="' . $builder->getBoundary() . '"',
                'Content-Length' => \strlen($body)
            ],
            'body' => $body
        ];
        return $array;
    }
public function constructMultipartOptions ( array $ data , array $ multipart_data ) : array { $ builder = new Builder ( ) ; $ this -> logger -> debug ( 'Creating multi-part form array data (complex and expensive)' ) ; foreach ( $ data as $ id => $ value ) { if ( array_key_exists ( $ id , $ multipart_data ) ) { $ data = new MultipartData ( ( string ) $ multipart_data [ $ id ] [ 'id' ] , stream_get_contents ( $ multipart_data [ $ id ] [ 'stream' ] ) , pathinfo ( $ multipart_data [ $ id ] [ 'filename' ] , PATHINFO_BASENAME ) ) ; $ builder -> append ( $ data ) ; } elseif ( $ id == 'mediagroup' ) { foreach ( $ multipart_data as $ ii => $ mdata ) { $ data = new MultipartData ( pathinfo ( $ mdata [ 'filename' ] , PATHINFO_BASENAME ) , stream_get_contents ( $ mdata [ 'stream' ] ) , pathinfo ( $ mdata [ 'filename' ] , PATHINFO_BASENAME ) ) ; $ builder -> append ( $ data ) ; } } else { $ data = new MultipartData ( ( string ) $ id , ( string ) $ value ) ; $ builder -> append ( $ data ) ; } } $ body = $ builder -> buildAll ( ) ; $ array = [ 'headers' => [ 'Content-Type' => 'multipart/form-data; boundary="' . $ builder -> getBoundary ( ) . '"' , 'Content-Length' => \ strlen ( $ body ) ] , 'body' => $ body ] ; return $ array ; }
Builds up a multipart form-like array for Guzzle

@param array $data The original object in array form
@param string $fileKeyName A file handler will be sent instead of a string, state here which field it is
@param resource $stream The actual file handler
@param string $filename
@return array Returns the actual formdata to be sent
Builds up a multipart form - like array for Guzzle