DmitryDulepov\Realurl\Decoder\UrlDecoder::decodeSingleVariable PHP Method

decodeSingleVariable() protected method

Decodes a single variable and adds it to the list of request variables.
protected decodeSingleVariable ( array $varConfiguration, array &$pathSegments, array &$requestVariables, &$previousValue ) : void
$varConfiguration array
$pathSegments array
$requestVariables array
$previousValue
return void
    protected function decodeSingleVariable(array $varConfiguration, array &$pathSegments, array &$requestVariables, &$previousValue)
    {
        static $varProcessingFunctions = array('decodeUrlParameterBlockUsingValueMap', 'decodeUrlParameterBlockUsingNoMatch', 'decodeUrlParameterBlockUsingUserFunc', 'decodeUrlParameterBlockUsingLookupTable', 'decodeUrlParameterBlockUsingValueDefault', 'decodeUrlParameterBlockUseAsIs');
        if (count($pathSegments) > 0) {
            $getVarValue = count($pathSegments) > 0 ? array_shift($pathSegments) : '';
            if ($this->emptySegmentValue !== '' && $getVarValue === $this->emptySegmentValue) {
                $getVarValue = '';
            }
            $isFakeValue = false;
        } else {
            $getVarValue = '';
            $isFakeValue = true;
        }
        // TODO Possible hook here before any other function? Pass name, value, segments and config
        $handled = FALSE;
        if (!isset($varConfiguration['cond']) || $this->checkLegacyCondition($varConfiguration['cond'], $previousValue)) {
            foreach ($varProcessingFunctions as $varProcessingFunction) {
                if (isset($varConfiguration['GETvar'])) {
                    if ($this->{$varProcessingFunction}($varConfiguration, $getVarValue, $requestVariables, $pathSegments, $isFakeValue)) {
                        $previousValue = (string) end($requestVariables);
                        $handled = TRUE;
                        break;
                    }
                } else {
                    // TODO Log about bad configuration
                }
            }
        }
        if (!$handled && !$isFakeValue) {
            array_unshift($pathSegments, $getVarValue);
        }
    }