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

createPathCacheEntry() protected method

Find a page entry for the current segment and returns a PathCacheEntry for it.
protected createPathCacheEntry ( string $segment, array $pages, array &$shortcutPages ) : DmitryDulepov\Realurl\Cache\PathCacheEntry
$segment string
$pages array
$shortcutPages array
return DmitryDulepov\Realurl\Cache\PathCacheEntry | NULL
    protected function createPathCacheEntry($segment, array $pages, array &$shortcutPages)
    {
        $result = NULL;
        foreach ($pages as $page) {
            $originalMountPointPid = 0;
            if ($page['doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
                // Value is not relevant, key is!
                $shortcutPages[$page['uid']] = true;
            }
            while ($page['doktype'] == PageRepository::DOKTYPE_MOUNTPOINT && $page['mount_pid_ol'] == 1) {
                $originalMountPointPid = $page['uid'];
                $page = $this->pageRepository->getPage($page['mount_pid']);
                if (!is_array($page)) {
                    $this->tsfe->pageNotFoundAndExit('[realurl] Broken mount point at page with uid=' . $originalMountPointPid);
                }
            }
            $languageExceptionUids = (string) $this->configuration->get('pagePath/languageExceptionUids');
            if ($this->detectedLanguageId > 0 && !isset($page['_PAGES_OVERLAY']) && (empty($languageExceptionUids) || !GeneralUtility::inList($languageExceptionUids, $this->detectedLanguageId))) {
                $page = $this->pageRepository->getPageOverlay($page, (int) $this->detectedLanguageId);
            }
            foreach (self::$pageTitleFields as $field) {
                if (isset($page[$field]) && $page[$field] !== '' && $this->utility->convertToSafeString($page[$field], $this->separatorCharacter) === $segment) {
                    $result = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Cache\\PathCacheEntry');
                    /** @var \DmitryDulepov\Realurl\Cache\PathCacheEntry $result */
                    $result->setPageId((int) $page['uid']);
                    if ($this->mountPointVariable !== '') {
                        $result->setMountPoint($this->mountPointVariable);
                    }
                    if ($originalMountPointPid !== 0) {
                        // Mount point with mount_pid_ol==1
                        $this->mountPointVariable = $page['uid'] . '-' . $originalMountPointPid;
                        // No $this->mountPointStartPid here because this is a substituted page
                    } elseif ((int) $page['doktype'] === PageRepository::DOKTYPE_MOUNTPOINT) {
                        $this->mountPointVariable = $page['mount_pid'] . '-' . $page['uid'];
                        $this->mountPointStartPid = (int) $page['mount_pid'];
                    }
                    break 2;
                }
            }
        }
        return $result;
    }