protected function createPathComponentUsingRootline()
{
$mountPointParameter = '';
if (isset($this->urlParameters['MP'])) {
$mountPointParameter = $this->urlParameters['MP'];
unset($this->urlParameters['MP']);
}
$rootLineUtility = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\RootlineUtility', $this->urlParameters['id'], $mountPointParameter, $this->pageRepository);
/** @var \TYPO3\CMS\Core\Utility\RootlineUtility $rootLineUtility */
$rootLine = $rootLineUtility->get();
// Skip from the root of the tree to the first level of pages
while (count($rootLine) !== 0) {
$page = array_pop($rootLine);
if ($page['uid'] == $this->rootPageId) {
break;
}
}
$languageExceptionUids = (string) $this->configuration->get('pagePath/languageExceptionUids');
$enableLanguageOverlay = (int) $this->originalUrlParameters['L'] > 0 && (empty($languageExceptionUids) || !GeneralUtility::inList($languageExceptionUids, $this->sysLanguageUid));
$components = array();
$reversedRootLine = array_reverse($rootLine);
$rootLineMax = count($reversedRootLine) - 1;
for ($current = 0; $current <= $rootLineMax; $current++) {
$page = $reversedRootLine[$current];
// Skip if this page is excluded
if ($page['tx_realurl_exclude'] && $current !== $rootLineMax) {
continue;
}
if ($enableLanguageOverlay) {
$overlay = $this->pageRepository->getPageOverlay($page, (int) $this->originalUrlParameters['L']);
if (is_array($overlay)) {
$page = $overlay;
unset($overlay);
}
}
// if path override is set, use path segment also for all subpages to shorten the url and throw away all segments found so far
if ($page['tx_realurl_pathoverride'] && $page['tx_realurl_pathsegment'] !== '') {
$segment = trim($page['tx_realurl_pathsegment'], '/');
$segments = explode('/', $segment);
array_walk($segments, function (&$segments, $key) {
$segments[$key] = $this->utility->convertToSafeString($segments[$key], $this->separatorCharacter);
});
// Technically we could do with `$components = $segments` but it fills better to have overriden string here
$segment = implode('/', $segments);
$components = array($segment);
continue;
}
foreach (self::$pageTitleFields as $field) {
if (isset($page[$field]) && $page[$field] !== '') {
$segment = $this->utility->convertToSafeString($page[$field], $this->separatorCharacter);
if ($segment === '') {
$segment = $this->emptySegmentValue;
}
$components[] = $segment;
continue 2;
}
}
}
if (count($components) > 0) {
foreach ($components as $segment) {
$this->appendToEncodedUrl($segment);
}
if ($reversedRootLine[$rootLineMax]['doktype'] != PageRepository::DOKTYPE_SPACER && $reversedRootLine[$rootLineMax]['doktype'] != PageRepository::DOKTYPE_RECYCLER) {
$this->addToPathCache(implode('/', $components));
}
}
}