Skip to content

Commit

Permalink
Merge pull request #222 from b13/rootflag
Browse files Browse the repository at this point in the history
[TASK] make templates without root-flag themeable
  • Loading branch information
kaystrobach authored Sep 16, 2021
2 parents ea33870 + b790902 commit fe01999
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Classes/Utilities/CheckPageUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
***************************************************************/

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -84,16 +86,31 @@ public static function hasThemeableSysTemplateRecord($pid)
->getQueryBuilderForTable('sys_template');
$queryBuilder->select('*')
->from('sys_template')
->andWhere(
->where(
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT)
),
)
);
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
$themeableSysTemplateRecordsRequireRootFlag = true;
try {
$site = $siteFinder->getSiteByPageId($pid);
$configuration = $site->getConfiguration();
if (isset($configuration['themeableSysTemplateRecordsRequireRootFlag'])) {
$themeableSysTemplateRecordsRequireRootFlag = (bool)$configuration['themeableSysTemplateRecordsRequireRootFlag'];
}
} catch (SiteNotFoundException $e) {
// simple keep variable value
}
if ($themeableSysTemplateRecordsRequireRootFlag === true) {
$queryBuilder->andWhere(
$queryBuilder->expr()->eq(
'root',
$queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)
)
);
}
/** @var \Doctrine\DBAL\Driver\Statement $statement */
$statement = $queryBuilder->execute();
if ($statement->rowCount() > 0) {
Expand Down

0 comments on commit fe01999

Please sign in to comment.