src/Core/StackUri.php
public function addOverridingOptions($options)
    {
        $part = 0;
        // if stack already has operations we assume we don't want to add more, it's just overriding parameters
        if (\count($this->getStackOperations()) > 0) {
            ++$part;
        }
        foreach (explode('/', $options) as $option) {
            ++$part;
            foreach (explode('--', $option) as $stringOperation) {
                $stringOperationWithOptions = explode('-', $stringOperation);
                $stringOperationName = $stringOperationWithOptions[0];
                if ('' == $stringOperationName) {
                    continue;
                }
                $parsedOptions = self::parseOptions(\array_slice($stringOperationWithOptions, 1));
                if ('options' === $stringOperationName || 'o' === $stringOperationName) {
                    $this->setStackOptions(array_merge($this->getStackOptions(), $parsedOptions));
                } elseif ('variables' === $stringOperationName || 'v' === $stringOperationName) {
                    $this->setStackVariables(array_merge($this->getStackVariables(), $parsedOptions));
                } else {
                    // move options with [] as start and end to expressions
                    $expressions = [];
                    foreach ($parsedOptions as $_k => $_v) {
                        if ('[' === substr($_v, 0, 1) && ']' === substr($_v, -1, 1)) {
                            $expressions[$_k] = substr($_v, 1, -1);
                            unset($parsedOptions[$_k]);

                            continue;
                        }
                        // it may be urlencoded, try that and decode
                        if ('%5B' === substr($_v, 0, 3) && '%5D' === substr($_v, -3, 3)) {
                            $expressions[$_k] = urldecode(substr($_v, 3, -3));
                            unset($parsedOptions[$_k]);
                        }
                        // only add as stack operation everything before the first /
                    }
                    if (1 === $part) {
                        $stackOperation = new StackOperation($stringOperationName, $parsedOptions, $expressions);
                        $this->addStackOperation($stackOperation);
                    } else {
                        $stackOperations = $this->getStackOperationsByName($stringOperationName);
                        foreach ($stackOperations as $stackOperation) {
                            $stackOperation->options = array_merge($stackOperation->options, $parsedOptions, $expressions);
                        }
                    }
                }
            }
        }

        return $this;
    }
public function addOverridingOptions($options)
    {
        $part = 0;
        // if stack already has operations we assume we don't want to add more, it's just overriding parameters
        if (\count($this->getStackOperations()) > 0) {
            ++$part;
        }
        foreach (explode('/', $options) as $option) {
            ++$part;
            foreach (explode('--', $option) as $stringOperation) {
                $stringOperationWithOptions = explode('-', $stringOperation);
                $stringOperationName = $stringOperationWithOptions[0];
                if ('' == $stringOperationName) {
                    continue;
                }
                $parsedOptions = self::parseOptions(\array_slice($stringOperationWithOptions, 1));
                if ('options' === $stringOperationName || 'o' === $stringOperationName) {
                    $this->setStackOptions(array_merge($this->getStackOptions(), $parsedOptions));
                } elseif ('variables' === $stringOperationName || 'v' === $stringOperationName) {
                    $this->setStackVariables(array_merge($this->getStackVariables(), $parsedOptions));
                } else {
                    // move options with [] as start and end to expressions
                    $expressions = [];
                    foreach ($parsedOptions as $_k => $_v) {
                        if ('[' === substr($_v, 0, 1) && ']' === substr($_v, -1, 1)) {
                            $expressions[$_k] = substr($_v, 1, -1);
                            unset($parsedOptions[$_k]);

                            continue;
                        }
                        // it may be urlencoded, try that and decode
                        if ('%5B' === substr($_v, 0, 3) && '%5D' === substr($_v, -3, 3)) {
                            $expressions[$_k] = urldecode(substr($_v, 3, -3));
                            unset($parsedOptions[$_k]);
                        }
                        // only add as stack operation everything before the first /
                    }
                    if (1 === $part) {
                        $stackOperation = new StackOperation($stringOperationName, $parsedOptions, $expressions);
                        $this->addStackOperation($stackOperation);
                    } else {
                        $stackOperations = $this->getStackOperationsByName($stringOperationName);
                        foreach ($stackOperations as $stackOperation) {
                            $stackOperation->options = array_merge($stackOperation->options, $parsedOptions, $expressions);
                        }
                    }
                }
            }
        }

        return $this;
    }
public function addOverridingOptions ( $ options ) { $ part = 0 ; // if stack already has operations we assume we don't want to add more, it's just overriding parameters if ( \ count ( $ this -> getStackOperations ( ) ) > 0 ) { ++ $ part ; } foreach ( explode ( '/' , $ options ) as $ option ) { ++ $ part ; foreach ( explode ( '--' , $ option ) as $ stringOperation ) { $ stringOperationWithOptions = explode ( '-' , $ stringOperation ) ; $ stringOperationName = $ stringOperationWithOptions [ 0 ] ; if ( '' == $ stringOperationName ) { continue ; } $ parsedOptions = self :: parseOptions ( \ array_slice ( $ stringOperationWithOptions , 1 ) ) ; if ( 'options' === $ stringOperationName || 'o' === $ stringOperationName ) { $ this -> setStackOptions ( array_merge ( $ this -> getStackOptions ( ) , $ parsedOptions ) ) ; } elseif ( 'variables' === $ stringOperationName || 'v' === $ stringOperationName ) { $ this -> setStackVariables ( array_merge ( $ this -> getStackVariables ( ) , $ parsedOptions ) ) ; } else { // move options with [] as start and end to expressions $ expressions = [ ] ; foreach ( $ parsedOptions as $ _k => $ _v ) { if ( '[' === substr ( $ _v , 0 , 1 ) && ']' === substr ( $ _v , - 1 , 1 ) ) { $ expressions [ $ _k ] = substr ( $ _v , 1 , - 1 ) ; unset ( $ parsedOptions [ $ _k ] ) ; continue ; } // it may be urlencoded, try that and decode if ( '%5B' === substr ( $ _v , 0 , 3 ) && '%5D' === substr ( $ _v , - 3 , 3 ) ) { $ expressions [ $ _k ] = urldecode ( substr ( $ _v , 3 , - 3 ) ) ; unset ( $ parsedOptions [ $ _k ] ) ; } // only add as stack operation everything before the first / } if ( 1 === $ part ) { $ stackOperation = new StackOperation ( $ stringOperationName , $ parsedOptions , $ expressions ) ; $ this -> addStackOperation ( $ stackOperation ) ; } else { $ stackOperations = $ this -> getStackOperationsByName ( $ stringOperationName ) ; foreach ( $ stackOperations as $ stackOperation ) { $ stackOperation -> options = array_merge ( $ stackOperation -> options , $ parsedOptions , $ expressions ) ; } } } } } return $ this ; }
For overwriting stack operation options or adding stack options.

The format of the $options parameter is the same as you would use for overwriting ooptions via a render URL.

Example: 'resize-width-200--options-dpr-2-autoformat-true'

Using '/' instead of '--' is also valid, but if the object doesn't have operations defined already, the behaviour
is different
Examples:

'resize-width-200--crop-width-200-height-200' <- resizes and crops and image
'resize-width-200/crop-width-200-height-200' <- only resized the image, since the crop is an overwrite and the operation doesnt exist

But if there's already stack operations for resize and crop defined in the object, both above examples do the
same.

@see https://rokka.io/documentation/references/render.html#overwriting-stack-operation-options
@since 1.2.0

@param string $options The same format as overwriting stack operations options via url

@return StackUri
For overwriting stack operation options or adding stack options .