src/Image.php
public function setDynamicMetadata($dynamicMetadata, $hash, $organization = '', $options = [])
    {
        if (!\is_array($dynamicMetadata)) {
            $dynamicMetadata = [$dynamicMetadata];
        }

        $count = 0;
        $response = null;
        foreach ($dynamicMetadata as $value => $data) {
            $callOptions = [];
            if ($data instanceof DynamicMetadataInterface) {
                $name = $data::getName();
                $callOptions['json'] = $data->getForJson();
            } else {
                $name = $value;
                $callOptions['json'] = $data;
            }

            $path = implode('/', [
                self::SOURCEIMAGE_RESOURCE,
                $this->getOrganizationName($organization),
                $hash,
                self::DYNAMIC_META_RESOURCE,
                $name,
            ]);

            // delete the previous, if we're not on the first one anymore, or if we want to delete it.
            if ($count > 0 || (0 === $count && isset($options['deletePrevious']) && $options['deletePrevious'])) {
                $callOptions['query'] = ['deletePrevious' => 'true'];
            }

            ++$count;
            $response = $this->call('PUT', $path, $callOptions);
            if (!($response->getStatusCode() >= 200 && $response->getStatusCode() < 300)) {
                throw new \LogicException($response->getBody()->getContents(), $response->getStatusCode());
            }
            $hash = $this->extractHashFromLocationHeader($response->getHeader('Location'));
        }
        if ($response instanceof ResponseInterface) {
            if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
                return $hash;
            }
            // Throw an exception to be handled by the caller.
            throw new \LogicException($response->getBody()->getContents(), $response->getStatusCode());
        }

        throw new \LogicException('Something went wrong with the call/response to the rokka API', 0);
    }
public function setDynamicMetadata($dynamicMetadata, $hash, $organization = '', $options = [])
    {
        if (!\is_array($dynamicMetadata)) {
            $dynamicMetadata = [$dynamicMetadata];
        }

        $count = 0;
        $response = null;
        foreach ($dynamicMetadata as $value => $data) {
            $callOptions = [];
            if ($data instanceof DynamicMetadataInterface) {
                $name = $data::getName();
                $callOptions['json'] = $data->getForJson();
            } else {
                $name = $value;
                $callOptions['json'] = $data;
            }

            $path = implode('/', [
                self::SOURCEIMAGE_RESOURCE,
                $this->getOrganizationName($organization),
                $hash,
                self::DYNAMIC_META_RESOURCE,
                $name,
            ]);

            // delete the previous, if we're not on the first one anymore, or if we want to delete it.
            if ($count > 0 || (0 === $count && isset($options['deletePrevious']) && $options['deletePrevious'])) {
                $callOptions['query'] = ['deletePrevious' => 'true'];
            }

            ++$count;
            $response = $this->call('PUT', $path, $callOptions);
            if (!($response->getStatusCode() >= 200 && $response->getStatusCode() < 300)) {
                throw new \LogicException($response->getBody()->getContents(), $response->getStatusCode());
            }
            $hash = $this->extractHashFromLocationHeader($response->getHeader('Location'));
        }
        if ($response instanceof ResponseInterface) {
            if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
                return $hash;
            }
            // Throw an exception to be handled by the caller.
            throw new \LogicException($response->getBody()->getContents(), $response->getStatusCode());
        }

        throw new \LogicException('Something went wrong with the call/response to the rokka API', 0);
    }
public function setDynamicMetadata ( $ dynamicMetadata , $ hash , $ organization = '' , $ options = [ ] ) { if ( ! \ is_array ( $ dynamicMetadata ) ) { $ dynamicMetadata = [ $ dynamicMetadata ] ; } $ count = 0 ; $ response = null ; foreach ( $ dynamicMetadata as $ value => $ data ) { $ callOptions = [ ] ; if ( $ data instanceof DynamicMetadataInterface ) { $ name = $ data :: getName ( ) ; $ callOptions [ 'json' ] = $ data -> getForJson ( ) ; } else { $ name = $ value ; $ callOptions [ 'json' ] = $ data ; } $ path = implode ( '/' , [ self :: SOURCEIMAGE_RESOURCE , $ this -> getOrganizationName ( $ organization ) , $ hash , self :: DYNAMIC_META_RESOURCE , $ name , ] ) ; // delete the previous, if we're not on the first one anymore, or if we want to delete it. if ( $ count > 0 || ( 0 === $ count && isset ( $ options [ 'deletePrevious' ] ) && $ options [ 'deletePrevious' ] ) ) { $ callOptions [ 'query' ] = [ 'deletePrevious' => 'true' ] ; } ++ $ count ; $ response = $ this -> call ( 'PUT' , $ path , $ callOptions ) ; if ( ! ( $ response -> getStatusCode ( ) >= 200 && $ response -> getStatusCode ( ) < 300 ) ) { throw new \ LogicException ( $ response -> getBody ( ) -> getContents ( ) , $ response -> getStatusCode ( ) ) ; } $ hash = $ this -> extractHashFromLocationHeader ( $ response -> getHeader ( 'Location' ) ) ; } if ( $ response instanceof ResponseInterface ) { if ( $ response -> getStatusCode ( ) >= 200 && $ response -> getStatusCode ( ) < 300 ) { return $ hash ; } // Throw an exception to be handled by the caller. throw new \ LogicException ( $ response -> getBody ( ) -> getContents ( ) , $ response -> getStatusCode ( ) ) ; } throw new \ LogicException ( 'Something went wrong with the call/response to the rokka API' , 0 ) ; }
Add the given DynamicMetadata to a SourceImage.
Returns the new Hash for the SourceImage, it could be the same as the input one if the operation
did not change it.

The only option currently can be
['deletePrevious' => true]

which deletes the previous image from rokka (but not the binary, since that's still used)
If not set, the original image is kept in rokka.

@param DynamicMetadataInterface|array $dynamicMetadata A Dynamic Metadata object, an array with all the needed info.
Or an array with more than one of those.
@param string                         $hash            The Image hash
@param string                         $organization    Optional organization name
@param array                          $options         Optional options

@throws GuzzleException
@throws \RuntimeException

@return string|false
Add the given DynamicMetadata to a SourceImage . Returns the new Hash for the SourceImage it could be the same as the input one if the operation did not change it .