|
|
@@ -3,6 +3,8 @@
|
|
|
namespace Opentalent\OtTemplating\Page;
|
|
|
|
|
|
use FluidTYPO3\Vhs\Service\PageService;
|
|
|
+use TYPO3\CMS\Core\Exception\SiteNotFoundException;
|
|
|
+use TYPO3\CMS\Core\Site\SiteFinder;
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
|
|
use TYPO3\CMS\Frontend\Page\PageRepository;
|
|
|
@@ -46,7 +48,6 @@ class OtPageRepository extends PageRepository
|
|
|
* @return array
|
|
|
*/
|
|
|
public function getRootPageFor($pageUid) {
|
|
|
-
|
|
|
$pageService = GeneralUtility::makeInstance(ObjectManager::class)->get(PageService::class);
|
|
|
$rootLine = $pageService->getRootLine($pageUid);
|
|
|
|
|
|
@@ -88,18 +89,16 @@ class OtPageRepository extends PageRepository
|
|
|
|
|
|
/**
|
|
|
* Returns the current site template's name
|
|
|
- * @param $pageUid
|
|
|
* @return string
|
|
|
*/
|
|
|
- public function getCurrentTemplate($pageUid) {
|
|
|
- $rootPageUid = $this->getRootPageFor($pageUid)['uid'];
|
|
|
+ public function getCurrentTemplate() {
|
|
|
+ $rootPageUid = $this->getCurrentSiteRootPageId();
|
|
|
if (!($rootPageUid >= 0)) {
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
$rootPage = $this->getPage($rootPageUid);
|
|
|
$templateName = $rootPage['tx_opentalent_template'];
|
|
|
-
|
|
|
if ($templateName==='') {
|
|
|
return self::defaultTemplate;
|
|
|
}
|
|
|
@@ -108,11 +107,10 @@ class OtPageRepository extends PageRepository
|
|
|
|
|
|
/**
|
|
|
* Returns the current site template's name
|
|
|
- * @param $pageUid
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getTemplatePreferences($pageUid) {
|
|
|
- $rootPageUid = $this->getRootPageFor($pageUid)['uid'];
|
|
|
+ public function getTemplatePreferences() {
|
|
|
+ $rootPageUid = $this->getCurrentSiteRootPageId();
|
|
|
if (!($rootPageUid >= 0)) {
|
|
|
return [];
|
|
|
}
|
|
|
@@ -126,5 +124,39 @@ class OtPageRepository extends PageRepository
|
|
|
return json_decode($templatePreferences, true);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the typo3 site matching the current request
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function getCurrentSite() {
|
|
|
+ $request = $GLOBALS['TYPO3_REQUEST'];
|
|
|
+ $site = $request->getAttribute('site');
|
|
|
+ return GeneralUtility::makeInstance(SiteFinder::class)
|
|
|
+ ->getSiteByIdentifier($site->getIdentifier());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function getCurrentSiteRootPageId() {
|
|
|
+ $site = $this->getCurrentSite();
|
|
|
+ return $site->getRootPageId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function getCurrentSiteRootPageUri() {
|
|
|
+ $site = $this->getCurrentSite();
|
|
|
+ return $site->getBase();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function getCurrentSiteRootPage() {
|
|
|
+ $uid = $this->getCurrentSiteRootPageUri();
|
|
|
+ return $this->getPage($uid);
|
|
|
+ }
|
|
|
|
|
|
}
|