/**
* Gets a collection of path configurations for content elements
* based on each root TypoScript template in the provided array
* of templates. Returns an array of paths indexed by the root
* page UID.
*
* @param array $templates
* @return array
*/
protected function getPathConfigurationsFromRootTypoScriptTemplates($templates)
{
$allTemplatePaths = array();
$registeredExtensionKeys = Core::getRegisteredProviderExtensionKeys('Content');
foreach ($templates as $templateRecord) {
$pageUid = $templateRecord['pid'];
/** @var \TYPO3\CMS\Core\TypoScript\ExtendedTemplateService $template */
$template = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
$template->tt_track = 0;
$template->init();
/** @var \TYPO3\CMS\Frontend\Page\PageRepository $sys_page */
$sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$rootLine = $sys_page->getRootLine($pageUid);
$template->runThroughTemplates($rootLine);
$template->generateConfig();
$oldTemplatePathLocation = (array) $template->setup['plugin.']['tx_fed.']['fce.'];
$newTemplatePathLocation = (array) $template->setup['plugin.']['tx_fluidcontent.']['collections.'];
$registeredPathCollections = array();
foreach ($registeredExtensionKeys as $registeredExtensionKey) {
$nativeViewLocation = $this->getContentConfiguration($registeredExtensionKey);
if (FALSE === isset($nativeViewLocation['extensionKey'])) {
$nativeViewLocation['extensionKey'] = ExtensionNamingUtility::getExtensionKey($registeredExtensionKey);
}
$registeredPathCollections[$registeredExtensionKey] = $nativeViewLocation;
}
$merged = GeneralUtility::array_merge_recursive_overrule($oldTemplatePathLocation, $newTemplatePathLocation);
$merged = GeneralUtility::removeDotsFromTS($merged);
$merged = GeneralUtility::array_merge($merged, $registeredPathCollections);
$allTemplatePaths[$pageUid] = $merged;
}
return $allTemplatePaths;
}