Skip to content

Commit

Permalink
[BUGFIX] Introduce XCLASS for frontendcontroller to ensure loading of…
Browse files Browse the repository at this point in the history
… tsconfig in FE
  • Loading branch information
sorenmalling committed Dec 12, 2018
1 parent f4ed886 commit 1ca5249
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Classes/Frontend/Controller/TypoScriptFrontendController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Meteko\Autosite\Frontend\Controller;

use TYPO3\CMS\Core\Package\Package;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class TypoScriptFrontendController extends \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController {


/**
* @inheritdoc
*/
public function getPagesTSconfig()
{
/** @var SiteFinder $siteFinder */
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
foreach ($this->rootLine as $key => $value) {
$site = $siteFinder->getSiteByPageId($value['uid']);

if (!($site instanceof Site)) {
continue;
}

/** @var PackageManager $packageManager */
$packageManager = GeneralUtility::makeInstance(PackageManager::class);
/** @var Package $package */
$package = $packageManager->getPackage($site->getIdentifier());
$tsConfigFile = $package->getPackagePath() . 'Configuration/PageTS/main.tsconfig';
if (file_exists($tsConfigFile)) {
$fileContents = @file_get_contents($tsConfigFile);
$this->rootLine[$key]['TSconfig'] .= LF . $fileContents;
}
}

return parent::getPagesTSconfig();
}
}
3 changes: 3 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
'addSiteConfiguration'
);

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class] = [
'className' => \Meteko\Autosite\Frontend\Controller\TypoScriptFrontendController::class
];

0 comments on commit 1ca5249

Please sign in to comment.