From ab6df2eabd9a0f1f8ed20f34e57796af20736386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Wolda=C5=84ski?= Date: Wed, 19 Oct 2022 17:17:06 +0200 Subject: [PATCH] [TASK] apply v11 improvements & remove deprecations - migrate TYPO3_MODE constants resolve #490 - simplify namespace importing in TYPO3 v11 --- .../RootSiteProcessing/SiteProvider.php | 5 +- Classes/Form/Translator.php | 3 +- Classes/Service/PaginationService.php | 2 +- .../Form/RegisterFieldViewHelper.php | 7 +- .../Format/Json/DecodeViewHelper.php | 9 +-- Classes/ViewHelpers/LoginFormViewHelper.php | 22 +++-- .../Controller/FormFrontendController.php | 5 +- Classes/XClass/ResourceLocalDriver.php | 3 +- Configuration/RequestMiddlewares.php | 17 ++-- Configuration/Services.php | 10 ++- .../SiteConfiguration/Overrides/site.php | 5 +- .../Overrides/site_base_variant.php | 5 +- Configuration/TCA/Overrides/sys_template.php | 8 +- .../ContentTypes/DefaultContentsTest.php | 3 +- ext_emconf.php | 1 - ext_localconf.php | 80 ++++++++++++------- ext_tables.php | 17 ++-- 17 files changed, 126 insertions(+), 76 deletions(-) diff --git a/Classes/DataProcessing/RootSiteProcessing/SiteProvider.php b/Classes/DataProcessing/RootSiteProcessing/SiteProvider.php index 40949ff9..ba6351f6 100644 --- a/Classes/DataProcessing/RootSiteProcessing/SiteProvider.php +++ b/Classes/DataProcessing/RootSiteProcessing/SiteProvider.php @@ -11,6 +11,7 @@ namespace FriendsOfTYPO3\Headless\DataProcessing\RootSiteProcessing; +use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Driver\Result; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; @@ -159,7 +160,7 @@ private function filterSites(array $allowedSites = []): array /** * @param int $pid * @return array - * @throws \Doctrine\DBAL\Driver\Exception + * @throws Exception */ private function fetchAvailableRootSitesByPid(int $pid): array { @@ -191,7 +192,7 @@ private function fetchAvailableRootSitesByPid(int $pid): array * @param array $sites * @param array $config * @return array - * @throws \Doctrine\DBAL\Driver\Exception + * @throws Exception */ private function fetchPageData(array $sites, array $config = []): array { diff --git a/Classes/Form/Translator.php b/Classes/Form/Translator.php index 3d2629cb..e15472c5 100644 --- a/Classes/Form/Translator.php +++ b/Classes/Form/Translator.php @@ -12,6 +12,7 @@ namespace FriendsOfTYPO3\Headless\Form; use FriendsOfTYPO3\Headless\Form\Service\FormTranslationService; +use TYPO3\CMS\Core\Utility\GeneralUtility; use function array_keys; use function array_merge; @@ -24,7 +25,7 @@ class Translator public function __construct(FormTranslationService $service = null) { - $this->translator = $service ?? FormTranslationService::getInstance(); + $this->translator = $service ?? GeneralUtility::makeInstance(FormTranslationService::class); } /** diff --git a/Classes/Service/PaginationService.php b/Classes/Service/PaginationService.php index ce48f9eb..c642d8a3 100644 --- a/Classes/Service/PaginationService.php +++ b/Classes/Service/PaginationService.php @@ -29,7 +29,7 @@ class PaginationService ]; /** - * @var \TYPO3\CMS\Extbase\Persistence\QueryResultInterface + * @var QueryResultInterface */ protected $objects; diff --git a/Classes/ViewHelpers/Form/RegisterFieldViewHelper.php b/Classes/ViewHelpers/Form/RegisterFieldViewHelper.php index c371bc47..1a617c96 100644 --- a/Classes/ViewHelpers/Form/RegisterFieldViewHelper.php +++ b/Classes/ViewHelpers/Form/RegisterFieldViewHelper.php @@ -11,17 +11,20 @@ namespace FriendsOfTYPO3\Headless\ViewHelpers\Form; +use TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\Exception; + /** * Registers field for generating hidden fields * * @codeCoverageIgnore */ -class RegisterFieldViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper +class RegisterFieldViewHelper extends AbstractFormFieldViewHelper { /** * Initialize the arguments. * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception + * @throws Exception */ public function initializeArguments() { diff --git a/Classes/ViewHelpers/Format/Json/DecodeViewHelper.php b/Classes/ViewHelpers/Format/Json/DecodeViewHelper.php index fd225ec1..c6b253f5 100644 --- a/Classes/ViewHelpers/Format/Json/DecodeViewHelper.php +++ b/Classes/ViewHelpers/Format/Json/DecodeViewHelper.php @@ -22,28 +22,25 @@ class DecodeViewHelper extends AbstractViewHelper */ public function initializeArguments(): void { - $this->registerArgument('json', 'string', 'json to decode', false, ''); + $this->registerArgument('json', 'string', 'json to decode', false); } /** - * @param string $json * @return mixed */ - public function render($json = null) + public function render() { + $json = $this->arguments['json']; if ($json === null) { $json = $this->renderChildren(); if (empty($json)) { return null; } } - $object = json_decode($json, true); - if (json_last_error() === JSON_ERROR_NONE) { return $object; } - if ($GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] ?? false) { throw new \Exception(sprintf( 'Failure "%s" occured when running json_decode() for string: %s', diff --git a/Classes/ViewHelpers/LoginFormViewHelper.php b/Classes/ViewHelpers/LoginFormViewHelper.php index a4417fa0..19d8a84b 100644 --- a/Classes/ViewHelpers/LoginFormViewHelper.php +++ b/Classes/ViewHelpers/LoginFormViewHelper.php @@ -11,7 +11,10 @@ namespace FriendsOfTYPO3\Headless\ViewHelpers; +use TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; +use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy; +use TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper; /** * Form ViewHelper. Generates a :html:`
` Tag. @@ -49,7 +52,7 @@ * * @codeCoverageIgnore */ -class LoginFormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper +class LoginFormViewHelper extends FormViewHelper { /** * @var array @@ -125,11 +128,6 @@ protected function setFormActionUri() ->setArgumentsToBeExcludedFromQueryString(isset($this->arguments['argumentsToBeExcludedFromQueryString']) ? (array)$this->arguments['argumentsToBeExcludedFromQueryString'] : []) ->setFormat($this->arguments['format'] ?? ''); - $addQueryStringMethod = $this->arguments['addQueryStringMethod'] ?? null; - if (is_string($addQueryStringMethod)) { - $uriBuilder->setAddQueryStringMethod($addQueryStringMethod); - } - $pageUid = (int)($this->arguments['pageUid'] ?? 0); if ($pageUid > 0) { $uriBuilder->setTargetPageUid($pageUid); @@ -154,8 +152,8 @@ protected function setFormActionUri() */ protected function renderAdditionalIdentityFields() { - if ($this->viewHelperVariableContainer->exists(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'additionalIdentityProperties')) { - $additionalIdentityProperties = $this->viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'additionalIdentityProperties'); + if ($this->viewHelperVariableContainer->exists(FormViewHelper::class, 'additionalIdentityProperties')) { + $additionalIdentityProperties = $this->viewHelperVariableContainer->get(FormViewHelper::class, 'additionalIdentityProperties'); $output = ''; foreach ($additionalIdentityProperties as $identity) { $this->addHiddenField('identity', $identity); @@ -208,7 +206,7 @@ protected function renderHiddenReferrerFields() protected function addFieldNamePrefixToViewHelperVariableContainer() { $fieldNamePrefix = $this->getFieldNamePrefix(); - $this->viewHelperVariableContainer->add(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix', $fieldNamePrefix); + $this->viewHelperVariableContainer->add(FormViewHelper::class, 'fieldNamePrefix', $fieldNamePrefix); } /** @@ -222,11 +220,11 @@ protected function addFieldNamePrefixToViewHelperVariableContainer() */ protected function renderHiddenIdentityField($object, $name) { - if ($object instanceof \TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy) { + if ($object instanceof LazyLoadingProxy) { $object = $object->_loadRealInstance(); } if (!is_object($object) - || !($object instanceof \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject) + || !($object instanceof AbstractDomainObject) || ($object->_isNew() && !$object->_isClone()) ) { return ''; @@ -250,7 +248,7 @@ protected function renderTrustedPropertiesField() { $formFieldNames = $this->viewHelperVariableContainer->get( - \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, + FormViewHelper::class, 'formFieldNames' ); $requestHash diff --git a/Classes/XClass/Controller/FormFrontendController.php b/Classes/XClass/Controller/FormFrontendController.php index 55514dc9..c7d8311e 100644 --- a/Classes/XClass/Controller/FormFrontendController.php +++ b/Classes/XClass/Controller/FormFrontendController.php @@ -19,6 +19,7 @@ use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Error\Error; use TYPO3\CMS\Extbase\Security\Cryptography\HashService; use TYPO3\CMS\Form\Domain\Factory\ArrayFormFactory; use TYPO3\CMS\Form\Domain\Model\FormDefinition; @@ -209,7 +210,7 @@ public function renderAction(): ResponseInterface $this->getControllerContext()->getRequest()->getMethod() === 'POST') { $result = $formRuntime->getRequest()->getOriginalRequestMappingResults(); /** - * @var array + * @var array */ $errors = $result->getFlattenedErrors(); $formStatus['status'] = $result->hasErrors() ? 'failure' : 'success'; @@ -231,7 +232,7 @@ public function renderAction(): ResponseInterface } /** - * @param array $errors + * @param array $errors * @param string $formIdentifier * @return array|null */ diff --git a/Classes/XClass/ResourceLocalDriver.php b/Classes/XClass/ResourceLocalDriver.php index 29c1d8f1..888ce021 100644 --- a/Classes/XClass/ResourceLocalDriver.php +++ b/Classes/XClass/ResourceLocalDriver.php @@ -14,13 +14,14 @@ use FriendsOfTYPO3\Headless\Utility\UrlUtility; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Http\ApplicationType; +use TYPO3\CMS\Core\Resource\Driver\LocalDriver; use TYPO3\CMS\Core\Resource\ResourceStorage; use TYPO3\CMS\Core\Utility\GeneralUtility; /** * @codeCoverageIgnore */ -class ResourceLocalDriver extends \TYPO3\CMS\Core\Resource\Driver\LocalDriver +class ResourceLocalDriver extends LocalDriver { protected function determineBaseUrl(): void { diff --git a/Configuration/RequestMiddlewares.php b/Configuration/RequestMiddlewares.php index f2f6c2ca..49b4e23b 100644 --- a/Configuration/RequestMiddlewares.php +++ b/Configuration/RequestMiddlewares.php @@ -7,8 +7,15 @@ * LICENSE.md file that was distributed with this source code. */ +use FriendsOfTYPO3\Headless\Middleware\ElementBodyResponseMiddleware; +use FriendsOfTYPO3\Headless\Middleware\RedirectHandler; +use FriendsOfTYPO3\Headless\Middleware\ShortcutAndMountPointRedirect; +use FriendsOfTYPO3\Headless\Middleware\UserIntMiddleware; +use TYPO3\CMS\Core\Configuration\Features; +use TYPO3\CMS\Core\Utility\GeneralUtility; + return (static function (): array { - $features = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\Features::class); + $features = GeneralUtility::makeInstance(Features::class); $middlewares = [ 'frontend' => [ @@ -16,7 +23,7 @@ 'after' => [ 'typo3/cms-frontend/content-length-headers', ], - 'target' => \FriendsOfTYPO3\Headless\Middleware\UserIntMiddleware::class + 'target' => UserIntMiddleware::class ], ], ]; @@ -26,7 +33,7 @@ 'after' => [ 'typo3/cms-adminpanel/data-persister', ], - 'target' => \FriendsOfTYPO3\Headless\Middleware\ElementBodyResponseMiddleware::class + 'target' => ElementBodyResponseMiddleware::class ]; } @@ -45,7 +52,7 @@ 'disabled' => true ], 'headless/cms-redirects/redirecthandler' => [ - 'target' => \FriendsOfTYPO3\Headless\Middleware\RedirectHandler::class, + 'target' => RedirectHandler::class, 'before' => [ $rearrangedMiddlewares ? 'typo3/cms-frontend/base-redirect-resolver' : 'typo3/cms-frontend/page-resolver', ], @@ -54,7 +61,7 @@ ], ], 'headless/cms-frontend/shortcut-and-mountpoint-redirect' => [ - 'target' => \FriendsOfTYPO3\Headless\Middleware\ShortcutAndMountPointRedirect::class, + 'target' => ShortcutAndMountPointRedirect::class, 'after' => [ 'typo3/cms-frontend/prepare-tsfe-rendering', ], diff --git a/Configuration/Services.php b/Configuration/Services.php index 275ab7f2..5a0573f2 100644 --- a/Configuration/Services.php +++ b/Configuration/Services.php @@ -8,10 +8,12 @@ */ declare(strict_types=1); - +use FriendsOfTYPO3\Headless\Seo\XmlSitemap\XmlSitemapRenderer; use FriendsOfTYPO3\Headless\Utility\HeadlessFrontendUrlInterface; use FriendsOfTYPO3\Headless\Utility\UrlUtility; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use TYPO3\CMS\Form\Controller\FormFrontendController; +use TYPO3\CMS\FrontendLogin\Controller\LoginController; return static function (ContainerConfigurator $configurator): void { $services = $configurator->services() @@ -24,7 +26,7 @@ $excludes = ['../Classes/Seo/XmlSitemap/XmlSitemapRenderer.php']; - if (!class_exists(\TYPO3\CMS\Form\Controller\FormFrontendController::class, false)) { + if (!class_exists(FormFrontendController::class, false)) { $excludes = array_merge($excludes, [ '../Classes/Form/*', '../Classes/XClass/Controller/FormFrontendController.php', @@ -32,7 +34,7 @@ ]); } - if (!class_exists(\TYPO3\CMS\FrontendLogin\Controller\LoginController::class, false)) { + if (!class_exists(LoginController::class, false)) { $excludes = array_merge($excludes, [ '../Classes/XClass/Controller/LoginController.php', ]); @@ -41,5 +43,5 @@ $toLoad->exclude($excludes); $services->set(HeadlessFrontendUrlInterface::class, UrlUtility::class)->autowire(false); - $services->set(FriendsOfTYPO3\Headless\Seo\XmlSitemap\XmlSitemapRenderer::class)->public()->share(false); + $services->set(XmlSitemapRenderer::class)->public()->share(false); }; diff --git a/Configuration/SiteConfiguration/Overrides/site.php b/Configuration/SiteConfiguration/Overrides/site.php index 71223c26..e308a2d9 100644 --- a/Configuration/SiteConfiguration/Overrides/site.php +++ b/Configuration/SiteConfiguration/Overrides/site.php @@ -7,7 +7,10 @@ * LICENSE.md file that was distributed with this source code. */ -$features = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\Features::class); +use TYPO3\CMS\Core\Configuration\Features; +use TYPO3\CMS\Core\Utility\GeneralUtility; + +$features = GeneralUtility::makeInstance(Features::class); if ($features->isFeatureEnabled('headless.frontendUrls')) { $tempColumns = [ diff --git a/Configuration/SiteConfiguration/Overrides/site_base_variant.php b/Configuration/SiteConfiguration/Overrides/site_base_variant.php index 514d8882..07c63e67 100644 --- a/Configuration/SiteConfiguration/Overrides/site_base_variant.php +++ b/Configuration/SiteConfiguration/Overrides/site_base_variant.php @@ -7,7 +7,10 @@ * LICENSE.md file that was distributed with this source code. */ -$features = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\Features::class); +use TYPO3\CMS\Core\Configuration\Features; +use TYPO3\CMS\Core\Utility\GeneralUtility; + +$features = GeneralUtility::makeInstance(Features::class); if ($features->isFeatureEnabled('headless.frontendUrls')) { $tempColumns = [ diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index aa35cc23..8304d9e7 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -7,13 +7,15 @@ * LICENSE.md file that was distributed with this source code. */ -defined('TYPO3_MODE') || die(); +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; + +defined('TYPO3') || die(); call_user_func(static function () { /** * Default TypoScript for Headless */ - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( + ExtensionManagementUtility::addStaticFile( 'headless', 'Configuration/TypoScript', 'Headless' @@ -21,7 +23,7 @@ /** * 2.x JSON response */ - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( + ExtensionManagementUtility::addStaticFile( 'headless', 'Configuration/TypoScript/2.x', 'Headless - 2.x JSON response' diff --git a/Tests/Functional/ContentTypes/DefaultContentsTest.php b/Tests/Functional/ContentTypes/DefaultContentsTest.php index b0080019..80122757 100644 --- a/Tests/Functional/ContentTypes/DefaultContentsTest.php +++ b/Tests/Functional/ContentTypes/DefaultContentsTest.php @@ -8,10 +8,11 @@ */ declare(strict_types=1); +use FriendsOfTYPO3\Headless\Test\Functional\ContentTypes\BaseContentTypeTest; use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest; -class DefaultContentsTest extends \FriendsOfTYPO3\Headless\Test\Functional\ContentTypes\BaseContentTypeTest +class DefaultContentsTest extends BaseContentTypeTest { public function testContentStructure() { diff --git a/ext_emconf.php b/ext_emconf.php index 7f3243e9..0ac08148 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -15,7 +15,6 @@ 'author_email' => 'extensions@macopedia.pl', 'author_company' => 'Macopedia Sp. z o.o.', 'category' => 'fe', - 'internal' => '', 'version' => '3.1.2', 'constraints' => [ 'depends' => [ diff --git a/ext_localconf.php b/ext_localconf.php index 0add05d8..d78b2162 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -7,80 +7,106 @@ * LICENSE.md file that was distributed with this source code. */ -defined('TYPO3_MODE') || die(); +use FriendsOfTYPO3\Headless\ContentObject\BooleanContentObject; +use FriendsOfTYPO3\Headless\ContentObject\FloatContentObject; +use FriendsOfTYPO3\Headless\ContentObject\IntegerContentObject; +use FriendsOfTYPO3\Headless\ContentObject\JsonContentContentObject; +use FriendsOfTYPO3\Headless\ContentObject\JsonContentObject; +use FriendsOfTYPO3\Headless\Hooks\FileOrFolderLinkBuilder; +use FriendsOfTYPO3\Headless\Hooks\TypolinkHook; +use FriendsOfTYPO3\Headless\Resource\Rendering\AudioTagRenderer; +use FriendsOfTYPO3\Headless\Resource\Rendering\VideoTagRenderer; +use FriendsOfTYPO3\Headless\Resource\Rendering\VimeoRenderer; +use FriendsOfTYPO3\Headless\Resource\Rendering\YouTubeRenderer; +use FriendsOfTYPO3\Headless\XClass\ResourceLocalDriver; +use TYPO3\CMS\Core\Configuration\Features; +use TYPO3\CMS\Core\Resource\Driver\LocalDriver; +use TYPO3\CMS\Core\Resource\Rendering\RendererRegistry; +use TYPO3\CMS\Core\Routing\PageRouter; +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Service\ImageService; +use TYPO3\CMS\Form\Controller\FormFrontendController; +use TYPO3\CMS\Form\Domain\Runtime\FormRuntime; +use TYPO3\CMS\Frontend\Typolink\PageLinkBuilder; +use TYPO3\CMS\FrontendLogin\Controller\LoginController; +use TYPO3\CMS\Workspaces\Controller\PreviewController; +use TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder; + +defined('TYPO3') || die(); call_user_func( static function () { $GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'][] = 'headless/Configuration/TypoScript/'; $GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects'] = array_merge($GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects'], [ - 'JSON' => \FriendsOfTYPO3\Headless\ContentObject\JsonContentObject::class, - 'CONTENT_JSON' => \FriendsOfTYPO3\Headless\ContentObject\JsonContentContentObject::class, - 'INT' => \FriendsOfTYPO3\Headless\ContentObject\IntegerContentObject::class, - 'FLOAT' => \FriendsOfTYPO3\Headless\ContentObject\FloatContentObject::class, - 'BOOL' => \FriendsOfTYPO3\Headless\ContentObject\BooleanContentObject::class, + 'JSON' => JsonContentObject::class, + 'CONTENT_JSON' => JsonContentContentObject::class, + 'INT' => IntegerContentObject::class, + 'FLOAT' => FloatContentObject::class, + 'BOOL' => BooleanContentObject::class, ]); - $GLOBALS['TYPO3_CONF_VARS']['FE']['typolinkBuilder']['file'] = \FriendsOfTYPO3\Headless\Hooks\FileOrFolderLinkBuilder::class; + $GLOBALS['TYPO3_CONF_VARS']['FE']['typolinkBuilder']['file'] = FileOrFolderLinkBuilder::class; $GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['headless'] = [ 'FriendsOfTYPO3\Headless\ViewHelpers' ]; - $features = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\Features::class); + $features = GeneralUtility::makeInstance(Features::class); if ($features->isFeatureEnabled('headless.frontendUrls')) { - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Core\Routing\PageRouter::class] = [ + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][PageRouter::class] = [ 'className' => FriendsOfTYPO3\Headless\XClass\Routing\PageRouter::class ]; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::class] = [ + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][PageLinkBuilder::class] = [ 'className' => FriendsOfTYPO3\Headless\XClass\Typolink\PageLinkBuilder::class, ]; } if ($features->isFeatureEnabled('headless.storageProxy')) { - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Core\Resource\Driver\LocalDriver::class] = [ - 'className' => FriendsOfTYPO3\Headless\XClass\ResourceLocalDriver::class + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][LocalDriver::class] = [ + 'className' => ResourceLocalDriver::class ]; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Extbase\Service\ImageService::class] = [ + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][ImageService::class] = [ 'className' => FriendsOfTYPO3\Headless\XClass\ImageService::class ]; } - if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('form')) { - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Form\Controller\FormFrontendController::class] = [ + if (ExtensionManagementUtility::isLoaded('form')) { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][FormFrontendController::class] = [ 'className' => FriendsOfTYPO3\Headless\XClass\Controller\FormFrontendController::class ]; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Form\Domain\Runtime\FormRuntime::class] = [ + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][FormRuntime::class] = [ 'className' => FriendsOfTYPO3\Headless\XClass\FormRuntime::class ]; } - if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('felogin')) { - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\FrontendLogin\Controller\LoginController::class] = [ + if (ExtensionManagementUtility::isLoaded('felogin')) { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][LoginController::class] = [ 'className' => FriendsOfTYPO3\Headless\XClass\Controller\LoginController::class ]; } - if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces') && $features->isFeatureEnabled('headless.workspaces')) { - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Workspaces\Controller\PreviewController::class] = [ + if (ExtensionManagementUtility::isLoaded('workspaces') && $features->isFeatureEnabled('headless.workspaces')) { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][PreviewController::class] = [ 'className' => FriendsOfTYPO3\Headless\XClass\Controller\PreviewController::class ]; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::class] = [ + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][PreviewUriBuilder::class] = [ 'className' => FriendsOfTYPO3\Headless\XClass\Preview\PreviewUriBuilder::class ]; } if ($features->isFeatureEnabled('headless.supportOldPageOutput')) { $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typoLink_PostProc'][] = - \FriendsOfTYPO3\Headless\Hooks\TypolinkHook::class . '->handleLink'; + TypolinkHook::class . '->handleLink'; } - $rendererRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::class); - $rendererRegistry->registerRendererClass(\FriendsOfTYPO3\Headless\Resource\Rendering\YouTubeRenderer::class); - $rendererRegistry->registerRendererClass(\FriendsOfTYPO3\Headless\Resource\Rendering\VimeoRenderer::class); - $rendererRegistry->registerRendererClass(\FriendsOfTYPO3\Headless\Resource\Rendering\AudioTagRenderer::class); - $rendererRegistry->registerRendererClass(\FriendsOfTYPO3\Headless\Resource\Rendering\VideoTagRenderer::class); + $rendererRegistry = GeneralUtility::makeInstance(RendererRegistry::class); + $rendererRegistry->registerRendererClass(YouTubeRenderer::class); + $rendererRegistry->registerRendererClass(VimeoRenderer::class); + $rendererRegistry->registerRendererClass(AudioTagRenderer::class); + $rendererRegistry->registerRendererClass(VideoTagRenderer::class); unset($rendererRegistry); } ); diff --git a/ext_tables.php b/ext_tables.php index 573c5bf0..aec3fd37 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -7,25 +7,30 @@ * LICENSE.md file that was distributed with this source code. */ -defined('TYPO3_MODE') || die(); +use FriendsOfTYPO3\Headless\Controller\JsonViewController; +use FriendsOfTYPO3\Headless\Hooks\PreviewUrlHook; +use TYPO3\CMS\Core\Configuration\Features; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Utility\ExtensionUtility; + +defined('TYPO3') || die(); call_user_func( static function () { - $features = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\Features::class); - $typo3Version = new TYPO3\CMS\Core\Information\Typo3Version(); + $features = GeneralUtility::makeInstance(Features::class); if ($features->isFeatureEnabled('headless.frontendUrls')) { - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['viewOnClickClass'][] = \FriendsOfTYPO3\Headless\Hooks\PreviewUrlHook::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['viewOnClickClass'][] = PreviewUrlHook::class; } if ($features->isFeatureEnabled('headless.jsonViewModule')) { - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( + ExtensionUtility::registerModule( 'Headless', 'web', 'jsonview', 'bottom', [ - \FriendsOfTYPO3\Headless\Controller\JsonViewController::class => 'main' + JsonViewController::class => 'main' ], [ 'access' => 'admin',