core-bundle/src/Routing/Matcher/LegacyMatcher.php
public function matchRequest(Request $request): array
    {
        $this->framework->initialize(true);

        $pathInfo = rawurldecode($request->getPathInfo());

        if (
            '/' === $pathInfo
            || empty($GLOBALS['TL_HOOKS']['getPageIdFromUrl'])
            || !\is_array($GLOBALS['TL_HOOKS']['getPageIdFromUrl'])
            || ($this->prependLocale && preg_match('@^/([a-z]{2}(-[A-Z]{2})?)/$@', $pathInfo))
        ) {
            return $this->requestMatcher->matchRequest($request);
        }

        @trigger_error('Using the "getPageIdFromUrl" hook has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);

        $locale = null;
        $fragments = null;

        /** @var Config $config */
        $config = $this->framework->getAdapter(Config::class);

        if ($config->get('folderUrl')) {
            try {
                $match = $this->requestMatcher->matchRequest($request);
                $fragments = $this->createFragmentsFromMatch($match);
                $locale = $match['_locale'] ?? null;
            } catch (ResourceNotFoundException $e) {
                // continue and parse fragments from path
            }
        }

        if (null === $fragments) {
            $pathInfo = $this->parseSuffixAndLanguage($pathInfo, $locale);
            $fragments = $this->createFragmentsFromPath($pathInfo);
        }

        if ($this->prependLocale) {
            if (null === $locale) {
                throw new ResourceNotFoundException('Locale is missing');
            }

            /** @var Input $input */
            $input = $this->framework->getAdapter(Input::class);
            $input->setGet('language', $locale);
        }

        $fragments = $this->executeLegacyHook($fragments);
        $pathInfo = $this->createPathFromFragments($fragments, $locale);

        return $this->requestMatcher->matchRequest($this->rebuildRequest($pathInfo, $request));
    }
public function matchRequest(Request $request): array
    {
        $this->framework->initialize(true);

        $pathInfo = rawurldecode($request->getPathInfo());

        if (
            '/' === $pathInfo
            || empty($GLOBALS['TL_HOOKS']['getPageIdFromUrl'])
            || !\is_array($GLOBALS['TL_HOOKS']['getPageIdFromUrl'])
            || ($this->prependLocale && preg_match('@^/([a-z]{2}(-[A-Z]{2})?)/$@', $pathInfo))
        ) {
            return $this->requestMatcher->matchRequest($request);
        }

        @trigger_error('Using the "getPageIdFromUrl" hook has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);

        $locale = null;
        $fragments = null;

        /** @var Config $config */
        $config = $this->framework->getAdapter(Config::class);

        if ($config->get('folderUrl')) {
            try {
                $match = $this->requestMatcher->matchRequest($request);
                $fragments = $this->createFragmentsFromMatch($match);
                $locale = $match['_locale'] ?? null;
            } catch (ResourceNotFoundException $e) {
                // continue and parse fragments from path
            }
        }

        if (null === $fragments) {
            $pathInfo = $this->parseSuffixAndLanguage($pathInfo, $locale);
            $fragments = $this->createFragmentsFromPath($pathInfo);
        }

        if ($this->prependLocale) {
            if (null === $locale) {
                throw new ResourceNotFoundException('Locale is missing');
            }

            /** @var Input $input */
            $input = $this->framework->getAdapter(Input::class);
            $input->setGet('language', $locale);
        }

        $fragments = $this->executeLegacyHook($fragments);
        $pathInfo = $this->createPathFromFragments($fragments, $locale);

        return $this->requestMatcher->matchRequest($this->rebuildRequest($pathInfo, $request));
    }
{@inheritdoc}