Commit 9aa18013 authored by Kevin Ditscheid's avatar Kevin Ditscheid

[BUGFIX] Fix annoying deprecations

parent 3e02043f
......@@ -26,16 +26,14 @@ namespace TYPO3\Languagevisibility\Hook;
***************************************************************/
use Exception;
use ReflectionException;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetPageOverlayHookInterface;
use TYPO3\CMS\Core\Domain\Repository\PageRepositoryGetRecordOverlayHookInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Page\PageRepository;
use TYPO3\CMS\Frontend\Page\PageRepositoryGetPageOverlayHookInterface;
use TYPO3\CMS\Frontend\Page\PageRepositoryGetRecordOverlayHookInterface;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\Languagevisibility\Exception\InvalidRowException;
use TYPO3\Languagevisibility\Exception\TableNotSupportedException;
use TYPO3\Languagevisibility\Service\FrontendServices;
......
......@@ -30,12 +30,21 @@ use Exception;
use TYPO3\CMS\Backend\Form\Element\AbstractFormElement;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Configuration\Loader\PageTsConfigLoader;
use TYPO3\CMS\Core\Configuration\Parser\PageTsConfigParser;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Hooks\PagesTsConfigGuard;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\RootlineUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
use TYPO3\Languagevisibility\Element\Element;
use TYPO3\Languagevisibility\Element\ElementFactory;
use TYPO3\Languagevisibility\Repository\VisibilityFlagRepository;
......@@ -78,7 +87,30 @@ class FieldVisibilityUserFunction extends AbstractFormElement {
/** @var BackendUserAuthentication $backendUser */
$backendUser = $GLOBALS['BE_USER'];
$this->modTSconfig = BackendUtility::getRawPagesTSconfig($pageId)['mod.']['languagevisibility.'];
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.2.0', '<')) {
$this->modTSconfig = BackendUtility::getRawPagesTSconfig($pageId)['mod.']['languagevisibility.'];
} else {
$rootline = GeneralUtility::makeInstance(RootlineUtility::class, $pageId)->get();
$contentHashCache = GeneralUtility::makeInstance(CacheManager::class)->getCache('hash');
$loader = GeneralUtility::makeInstance(PageTsConfigLoader::class);
$tsConfigString = $loader->load(array_reverse($rootline));
$parser = GeneralUtility::makeInstance(
PageTsConfigParser::class,
GeneralUtility::makeInstance(TypoScriptParser::class),
$contentHashCache
);
$pagesTSconfig = $parser->parse(
$tsConfigString,
GeneralUtility::makeInstance(
ConditionMatcher::class,
GeneralUtility::makeInstance(Context::class),
$pageId,
$rootline
),
GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageId)
);
$this->modTSconfig = $pagesTSconfig['mod.']['languagevisibility'];
}
$elementfactory = GeneralUtility::makeInstance(ElementFactory::class);
......
......@@ -25,14 +25,16 @@ namespace TYPO3\Languagevisibility\Xclass;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\Languagevisibility\Service\FrontendServices;
/**
* Class PageRepository
* @package TYPO3\Languagevisibility\Xclass
*/
class PageRepository extends \TYPO3\CMS\Frontend\Page\PageRepository {
class PageRepository extends \TYPO3\CMS\Core\Domain\Repository\PageRepository {
/**
* This just checks, if the wanted page is available for the current language with the languagevisibility filters
* from the backend. (The Table)
......@@ -54,7 +56,13 @@ class PageRepository extends \TYPO3\CMS\Frontend\Page\PageRepository {
return $page;
}
if (FrontendServices::checkVisiblityForElement($page, 'pages', $this->sys_language_uid)) {
if (
FrontendServices::checkVisiblityForElement(
$page,
'pages',
GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('language', 'id', 0)
)
) {
return $page;
}
......
......@@ -59,7 +59,7 @@ call_user_func(
['className' => \TYPO3\Languagevisibility\Xclass\Typo3DbBackend::class];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class] =
['className' => \TYPO3\Languagevisibility\Xclass\ContentObjectRenderer::class];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Frontend\Page\PageRepository::class] =
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Core\Domain\Repository\PageRepository::class] =
['className' => \TYPO3\Languagevisibility\Xclass\PageRepository::class];
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('mask')) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment