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

handleNonExistingPostVarSet() protected method

Handles non-existing postVarSet according to configuration.
protected handleNonExistingPostVarSet ( integer $pageId, string $postVarSetKey, array &$pathSegments )
$pageId integer
$postVarSetKey string
$pathSegments array
    protected function handleNonExistingPostVarSet($pageId, $postVarSetKey, array &$pathSegments)
    {
        $failureMode = $this->configuration->get('init/postVarSet_failureMode');
        if ($failureMode == 'redirect_goodUpperDir') {
            $nonProcessedArray = array($postVarSetKey) + $pathSegments;
            $badPathPart = implode('/', $nonProcessedArray);
            $badPathPartPos = strpos($this->originalPath, $badPathPart);
            $badPathPartLength = strlen($badPathPart);
            if ($badPathPartPos > 0) {
                // We also want to get rid of one slash
                $badPathPartPos--;
                $badPathPartLength++;
            }
            $goodPath = substr($this->originalPath, 0, $badPathPartPos) . substr($this->originalPath, $badPathPartPos + $badPathPartLength);
            @ob_end_clean();
            header(self::REDIRECT_STATUS_HEADER);
            header(self::REDIRECT_INFO_HEADER . ': postVarSet_failureMode redirect for ' . $postVarSetKey);
            header('Location: ' . GeneralUtility::locationHeaderUrl($goodPath));
            exit;
        } elseif ($failureMode == 'ignore') {
            $pathSegments = array();
        } else {
            $this->throw404('Segment "' . $postVarSetKey . '" was not a keyword for a postVarSet as expected on page with id=' . $pageId . '.');
        }
    }