DmitryDulepov\Realurl\Encoder\UrlEncoder::encodeSingleVariable PHP Method

encodeSingleVariable() protected method

Encodes a single variable for xxxVars.
protected encodeSingleVariable ( array $configuration, string &$previousValue, array &$segments )
$configuration array
$previousValue string
$segments array
    protected function encodeSingleVariable(array $configuration, &$previousValue, array &$segments)
    {
        static $varProcessingFunctions = array('encodeUrlParameterBlockUsingValueMap', 'encodeUrlParameterBlockUsingNoMatch', 'encodeUrlParameterBlockUsingUserFunc', 'encodeUrlParameterBlockUsingLookupTable', 'encodeUrlParameterBlockUsingValueDefault', 'encodeUrlParameterBlockUseAsIs');
        if (isset($configuration['GETvar'])) {
            $getVarName = $configuration['GETvar'];
            $getVarValue = isset($this->urlParameters[$getVarName]) ? $this->urlParameters[$getVarName] : '';
            if (!isset($configuration['cond']) || $this->checkLegacyCondition($configuration['cond'], $previousValue)) {
                // TODO Possible hook here before any other function? Pass name, value, segments and config
                foreach ($varProcessingFunctions as $varProcessingFunction) {
                    if ($this->{$varProcessingFunction}($getVarName, $getVarValue, $configuration, $segments, $previousValue)) {
                        // Unset to prevent further processing
                        unset($this->urlParameters[$getVarName]);
                        break;
                    }
                }
            }
        } else {
            // TODO Log an error here: configuration is bad!
        }
    }