From 6a336a3f94d9b3eaf17b534d87e34077211ee588 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Fri, 2 Dec 2022 15:02:38 +0100 Subject: [PATCH 01/13] [WIP] v12 Support first draft --- Classes/Updates/AuthorSlugUpdate.php | 2 +- Classes/Updates/AvatarProviderUpdate.php | 2 +- Classes/Updates/CategorySlugUpdate.php | 2 +- Classes/Updates/CategoryTypeUpdate.php | 2 +- Classes/Updates/TagSlugUpdate.php | 2 +- composer.json | 16 ++++++++-------- ext_localconf.php | 17 ++++++++++------- ext_tables.php | 2 -- 8 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Classes/Updates/AuthorSlugUpdate.php b/Classes/Updates/AuthorSlugUpdate.php index 2c7a9030..12653629 100644 --- a/Classes/Updates/AuthorSlugUpdate.php +++ b/Classes/Updates/AuthorSlugUpdate.php @@ -84,7 +84,7 @@ public function updateNecessary(): bool $queryBuilder->expr()->isNull($this->slugField) ) ) - ->execute()->fetchColumn(0); + ->execute()->fetchOne(); return (bool)$elementCount; } diff --git a/Classes/Updates/AvatarProviderUpdate.php b/Classes/Updates/AvatarProviderUpdate.php index d4856ba4..2bf95d21 100644 --- a/Classes/Updates/AvatarProviderUpdate.php +++ b/Classes/Updates/AvatarProviderUpdate.php @@ -102,7 +102,7 @@ public function updateNecessary(): bool ->where( $queryBuilder->expr()->eq('avatar_provider', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)) ) - ->execute()->fetchColumn(0); + ->execute()->fetchOne(); return (bool)$elementCount; } diff --git a/Classes/Updates/CategorySlugUpdate.php b/Classes/Updates/CategorySlugUpdate.php index 5d959a2d..9950ec05 100644 --- a/Classes/Updates/CategorySlugUpdate.php +++ b/Classes/Updates/CategorySlugUpdate.php @@ -84,7 +84,7 @@ public function updateNecessary(): bool $queryBuilder->expr()->isNull($this->slugField) ) ) - ->execute()->fetchColumn(0); + ->execute()->fetchOne(); return (bool)$elementCount; } diff --git a/Classes/Updates/CategoryTypeUpdate.php b/Classes/Updates/CategoryTypeUpdate.php index 22a41be1..3442c705 100644 --- a/Classes/Updates/CategoryTypeUpdate.php +++ b/Classes/Updates/CategoryTypeUpdate.php @@ -91,7 +91,7 @@ public function updateNecessary(): bool ) ) ->execute() - ->fetchColumn(0); + ->fetchOne(); return (bool)$elementCount; } diff --git a/Classes/Updates/TagSlugUpdate.php b/Classes/Updates/TagSlugUpdate.php index 1128e25e..2d72efb7 100644 --- a/Classes/Updates/TagSlugUpdate.php +++ b/Classes/Updates/TagSlugUpdate.php @@ -84,7 +84,7 @@ public function updateNecessary(): bool $queryBuilder->expr()->isNull($this->slugField) ) ) - ->execute()->fetchColumn(0); + ->execute()->fetchOne(); return (bool)$elementCount; } diff --git a/composer.json b/composer.json index 84ff9d96..f7451805 100644 --- a/composer.json +++ b/composer.json @@ -84,14 +84,14 @@ "ext-json": "*", "ext-pdo": "*", "psr/http-message": "^1.0", - "typo3/cms-backend": "^11.5", - "typo3/cms-core": "^11.5", - "typo3/cms-extbase": "^11.5", - "typo3/cms-extensionmanager": "^11.5", - "typo3/cms-fluid": "^11.5", - "typo3/cms-form": "^11.5", - "typo3/cms-frontend": "^11.5", - "typo3/cms-install": "^11.5", + "typo3/cms-backend": "^11.5 || ^12.0", + "typo3/cms-core": "^11.5 || ^12.0", + "typo3/cms-extbase": "^11.5 || ^12.0", + "typo3/cms-extensionmanager": "^11.5 || ^12.0", + "typo3/cms-fluid": "^11.5 || ^12.0", + "typo3/cms-form": "^11.5 || ^12.0", + "typo3/cms-frontend": "^11.5 || ^12.0", + "typo3/cms-install": "^11.5 || ^12.0", "typo3fluid/fluid": "^2.6", "psr/http-client": "^1.0", "psr/http-factory": "^1.0" diff --git a/ext_localconf.php b/ext_localconf.php index 14893795..f5ec034d 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -217,13 +217,16 @@ function () { ] ); - $dispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); - $dispatcher->connect( - \TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class, - 'afterExtensionInstall', - \T3G\AgencyPack\Blog\Hooks\ExtensionUpdate::class, - 'afterExtensionInstall' - ); + if ((\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class))->getMajorVersion() < 12) { + $dispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); + $dispatcher->connect( + \TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class, + 'afterExtensionInstall', + \T3G\AgencyPack\Blog\Hooks\ExtensionUpdate::class, + 'afterExtensionInstall' + ); + } + /** @noinspection UnsupportedStringOffsetOperationsInspection */ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['Blog'] = diff --git a/ext_tables.php b/ext_tables.php index eadcddcf..1a6d2d38 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -68,7 +68,6 @@ \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_blog_domain_model_comment'); - if (TYPO3_MODE === 'BE') { // Main Blog \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule( 'blog', @@ -126,5 +125,4 @@ 'access' => 'admin', ] ); - } }); From 7e26ce623450ce7b33fc35f6309ac6845451ad09 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Fri, 2 Dec 2022 15:59:29 +0100 Subject: [PATCH 02/13] [TASK] apply rector changes --- Classes/Controller/BackendController.php | 18 ++++++++++++------ .../Domain/Finisher/CommentFormFinisher.php | 6 +++--- Classes/ViewHelpers/GravatarViewHelper.php | 2 +- Classes/ViewHelpers/Link/ArchiveViewHelper.php | 2 +- Classes/ViewHelpers/Link/AuthorViewHelper.php | 2 +- .../ViewHelpers/Link/Be/AuthorViewHelper.php | 2 +- .../ViewHelpers/Link/Be/CategoryViewHelper.php | 2 +- .../ViewHelpers/Link/Be/CommentViewHelper.php | 2 +- Classes/ViewHelpers/Link/Be/PostViewHelper.php | 2 +- Classes/ViewHelpers/Link/Be/TagViewHelper.php | 2 +- .../ViewHelpers/Link/CategoryViewHelper.php | 2 +- Classes/ViewHelpers/Link/PostViewHelper.php | 2 +- Classes/ViewHelpers/Link/TagViewHelper.php | 2 +- Configuration/TCA/Overrides/sys_category.php | 1 - .../TCA/tx_blog_domain_model_author.php | 1 - .../TCA/tx_blog_domain_model_comment.php | 1 - 16 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index 7f000494..d321d3d1 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -60,6 +60,12 @@ class BackendController extends ActionController * @var CacheService */ protected $blogCacheService; + private \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer; + public function __construct(\TYPO3\CMS\Core\Imaging\IconFactory $iconFactory, \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer) + { + $this->iconFactory = $iconFactory; + $this->pageRenderer = $pageRenderer; + } /** * @param SetupService $setupService @@ -96,10 +102,10 @@ public function injectBlogCacheService(CacheService $cacheService): void public function initializeAction(): void { $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class); - $this->iconFactory = $this->moduleTemplate->getIconFactory(); + $this->iconFactory = $this->iconFactory; $this->buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); - $pageRenderer = $this->moduleTemplate->getPageRenderer(); + $pageRenderer = $this->pageRenderer; $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip'); $pageRenderer->addCssFile('EXT:blog/Resources/Public/Css/backend.min.css', 'stylesheet', 'all', '', false); } @@ -107,7 +113,7 @@ public function initializeAction(): void public function initializeSetupWizardAction(): void { $this->initializeDataTables(); - $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Blog/SetupWizard'); + $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Blog/SetupWizard'); } public function initializePostsAction(): void @@ -118,12 +124,12 @@ public function initializePostsAction(): void public function initializeCommentsAction(): void { $this->initializeDataTables(); - $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Blog/MassUpdate'); + $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Blog/MassUpdate'); } protected function initializeDataTables(): void { - $pageRenderer = $this->moduleTemplate->getPageRenderer(); + $pageRenderer = $this->pageRenderer; $pageRenderer->loadRequireJsModule('TYPO3/CMS/Blog/Datatables'); $pageRenderer->addCssFile('EXT:blog/Resources/Public/Css/Datatables.min.css', 'stylesheet', 'all', '', false); } @@ -253,7 +259,7 @@ public function createBlogAction(array $data = null): void if ($this->setupService->createBlogSetup($data)) { $this->addFlashMessage('Your blog setup has been created.', 'Congratulation'); } else { - $this->addFlashMessage('Sorry, your blog setup could not be created.', 'An error occurred', FlashMessage::ERROR); + $this->addFlashMessage('Sorry, your blog setup could not be created.', 'An error occurred', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR); } $this->redirect('setupWizard'); } diff --git a/Classes/Domain/Finisher/CommentFormFinisher.php b/Classes/Domain/Finisher/CommentFormFinisher.php index 179d0a52..c12d19ee 100644 --- a/Classes/Domain/Finisher/CommentFormFinisher.php +++ b/Classes/Domain/Finisher/CommentFormFinisher.php @@ -33,17 +33,17 @@ class CommentFormFinisher extends AbstractFinisher CommentService::STATE_ERROR => [ 'title' => 'message.addComment.error.title', 'text' => 'message.addComment.error.text', - 'severity' => FlashMessage::ERROR, + 'severity' => \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR, ], CommentService::STATE_MODERATION => [ 'title' => 'message.addComment.moderation.title', 'text' => 'message.addComment.moderation.text', - 'severity' => FlashMessage::INFO, + 'severity' => \TYPO3\CMS\Core\Messaging\AbstractMessage::INFO, ], CommentService::STATE_SUCCESS => [ 'title' => 'message.addComment.success.title', 'text' => 'message.addComment.success.text', - 'severity' => FlashMessage::OK, + 'severity' => \TYPO3\CMS\Core\Messaging\AbstractMessage::OK, ], ]; diff --git a/Classes/ViewHelpers/GravatarViewHelper.php b/Classes/ViewHelpers/GravatarViewHelper.php index 62e57f8c..7f58478b 100644 --- a/Classes/ViewHelpers/GravatarViewHelper.php +++ b/Classes/ViewHelpers/GravatarViewHelper.php @@ -26,7 +26,7 @@ public function __construct() /** * Arguments Initialization. * - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void diff --git a/Classes/ViewHelpers/Link/ArchiveViewHelper.php b/Classes/ViewHelpers/Link/ArchiveViewHelper.php index 73187c3b..f72a2133 100644 --- a/Classes/ViewHelpers/Link/ArchiveViewHelper.php +++ b/Classes/ViewHelpers/Link/ArchiveViewHelper.php @@ -24,7 +24,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Classes/ViewHelpers/Link/AuthorViewHelper.php b/Classes/ViewHelpers/Link/AuthorViewHelper.php index 9b9af4a9..c092412d 100644 --- a/Classes/ViewHelpers/Link/AuthorViewHelper.php +++ b/Classes/ViewHelpers/Link/AuthorViewHelper.php @@ -26,7 +26,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php b/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php index ecb46082..1fbbb3c7 100644 --- a/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php @@ -27,7 +27,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Classes/ViewHelpers/Link/Be/CategoryViewHelper.php b/Classes/ViewHelpers/Link/Be/CategoryViewHelper.php index f7f8a5d7..96d61426 100644 --- a/Classes/ViewHelpers/Link/Be/CategoryViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/CategoryViewHelper.php @@ -27,7 +27,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Classes/ViewHelpers/Link/Be/CommentViewHelper.php b/Classes/ViewHelpers/Link/Be/CommentViewHelper.php index 33f6a57c..706e5da6 100644 --- a/Classes/ViewHelpers/Link/Be/CommentViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/CommentViewHelper.php @@ -27,7 +27,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Classes/ViewHelpers/Link/Be/PostViewHelper.php b/Classes/ViewHelpers/Link/Be/PostViewHelper.php index 9cab8079..e394198e 100644 --- a/Classes/ViewHelpers/Link/Be/PostViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/PostViewHelper.php @@ -28,7 +28,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Classes/ViewHelpers/Link/Be/TagViewHelper.php b/Classes/ViewHelpers/Link/Be/TagViewHelper.php index 15344870..dd7e03ba 100644 --- a/Classes/ViewHelpers/Link/Be/TagViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/TagViewHelper.php @@ -27,7 +27,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Classes/ViewHelpers/Link/CategoryViewHelper.php b/Classes/ViewHelpers/Link/CategoryViewHelper.php index 4606efb0..3613b537 100644 --- a/Classes/ViewHelpers/Link/CategoryViewHelper.php +++ b/Classes/ViewHelpers/Link/CategoryViewHelper.php @@ -25,7 +25,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Classes/ViewHelpers/Link/PostViewHelper.php b/Classes/ViewHelpers/Link/PostViewHelper.php index f2b0fb2e..0c3c5885 100644 --- a/Classes/ViewHelpers/Link/PostViewHelper.php +++ b/Classes/ViewHelpers/Link/PostViewHelper.php @@ -25,7 +25,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Classes/ViewHelpers/Link/TagViewHelper.php b/Classes/ViewHelpers/Link/TagViewHelper.php index 62de24c9..5978b3f0 100644 --- a/Classes/ViewHelpers/Link/TagViewHelper.php +++ b/Classes/ViewHelpers/Link/TagViewHelper.php @@ -25,7 +25,7 @@ public function __construct() * Arguments initialization. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception + * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments(): void { diff --git a/Configuration/TCA/Overrides/sys_category.php b/Configuration/TCA/Overrides/sys_category.php index b7ff8f97..e256c725 100644 --- a/Configuration/TCA/Overrides/sys_category.php +++ b/Configuration/TCA/Overrides/sys_category.php @@ -108,7 +108,6 @@ 'config' => [ 'type' => 'group', 'size' => 5, - 'internal_type' => 'db', 'allowed' => 'pages', 'foreign_table' => 'pages', 'MM' => 'sys_category_record_mm', diff --git a/Configuration/TCA/tx_blog_domain_model_author.php b/Configuration/TCA/tx_blog_domain_model_author.php index 7910ecbe..8e901d71 100644 --- a/Configuration/TCA/tx_blog_domain_model_author.php +++ b/Configuration/TCA/tx_blog_domain_model_author.php @@ -244,7 +244,6 @@ 'label' => $ll . 'tx_blog_domain_model_author.details_page', 'config' => [ 'type' => 'group', - 'internal_type' => 'db', 'allowed' => 'pages', 'size' => 1, 'maxitems' => 1, diff --git a/Configuration/TCA/tx_blog_domain_model_comment.php b/Configuration/TCA/tx_blog_domain_model_comment.php index 9c855a10..9b1a2dbb 100644 --- a/Configuration/TCA/tx_blog_domain_model_comment.php +++ b/Configuration/TCA/tx_blog_domain_model_comment.php @@ -63,7 +63,6 @@ 'label' => $ll . 'tx_blog_domain_model_comment.author', 'config' => [ 'type' => 'group', - 'internal_type' => 'db', 'allowed' => 'fe_users', 'size' => 1, 'maxitems' => 1, From c36e29663645ec948f95cdf41889c403fdf7fd58 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Fri, 2 Dec 2022 17:06:11 +0100 Subject: [PATCH 03/13] [TASK] v12 Support * remove ObjectManager * doctrine fetch methods * extbase query constraints * remove extbase TS Configurations * use own FrontendUser Object --- Classes/AvatarProvider/GravatarProvider.php | 22 ++++-- Classes/AvatarProvider/ImageProvider.php | 21 +++-- Classes/Controller/PostController.php | 3 +- Classes/Domain/Factory/CommentFormFactory.php | 42 ++++++---- .../Domain/Finisher/CommentFormFinisher.php | 76 ++++++++++++++++--- Classes/Domain/Model/Comment.php | 3 +- Classes/Domain/Model/FrontendUser.php | 39 ++++++++++ Classes/Domain/Model/Post.php | 8 +- .../Domain/Repository/CategoryRepository.php | 24 ++++-- .../Domain/Repository/CommentRepository.php | 52 +++++++------ Classes/Domain/Repository/PostRepository.php | 51 +++++++------ Classes/Domain/Repository/TagRepository.php | 20 ++--- .../Validator/GoogleCaptchaValidator.php | 19 +++-- Classes/Hooks/DataHandlerHook.php | 2 +- Classes/Mail/MailContent.php | 28 ++++--- .../Processor/AdminNotificationProcessor.php | 20 +++-- .../Processor/AuthorNotificationProcessor.php | 19 +++-- .../Routing/Aspect/StaticDatabaseMapper.php | 2 +- Classes/Service/CommentService.php | 4 +- Classes/Service/SetupService.php | 6 +- Classes/Updates/AuthorSlugUpdate.php | 2 +- Classes/Updates/AvatarProviderUpdate.php | 2 +- Classes/Updates/CategorySlugUpdate.php | 4 +- Classes/Updates/CategoryTypeUpdate.php | 6 +- Classes/Updates/DatabaseMonthYearUpdate.php | 2 +- Classes/Updates/DatabasePublishDateUpdate.php | 2 +- Classes/Updates/FeaturedImageUpdate.php | 4 +- Classes/Updates/TagSlugUpdate.php | 2 +- .../Data/ContentListOptionsViewHelper.php | 20 +++-- .../ViewHelpers/Link/ArchiveViewHelper.php | 4 +- Classes/ViewHelpers/Link/AuthorViewHelper.php | 3 +- .../ViewHelpers/Link/CategoryViewHelper.php | 4 +- Classes/ViewHelpers/Link/PostViewHelper.php | 4 +- Classes/ViewHelpers/Link/TagViewHelper.php | 4 +- Configuration/Extbase/Persistence/Classes.php | 3 + Configuration/Services.yaml | 6 ++ ext_typoscript_setup.txt | 39 ---------- 37 files changed, 361 insertions(+), 211 deletions(-) create mode 100644 Classes/Domain/Model/FrontendUser.php diff --git a/Classes/AvatarProvider/GravatarProvider.php b/Classes/AvatarProvider/GravatarProvider.php index 0f0a9d3c..160673d3 100644 --- a/Classes/AvatarProvider/GravatarProvider.php +++ b/Classes/AvatarProvider/GravatarProvider.php @@ -24,8 +24,7 @@ use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\PathUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class GravatarProvider implements AvatarProviderInterface, SingletonInterface { @@ -63,13 +62,15 @@ final public function __construct() public function getAvatarUrl(Author $author): string { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $configurationManager = $objectManager->get(ConfigurationManagerInterface::class); - $settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); + $settings = []; + $frontendController = self::getTypoScriptFrontendController(); + if ($frontendController instanceof TypoScriptFrontendController) { + $settings = $frontendController->tmpl->setup['plugin.']['tx_blog.']['settings.'] ?? []; + } - $size = empty($size = (string)($settings['authors']['avatar']['provider']['size'] ?? '')) ? null : (int)$size; - $rating = empty($rating = (string)($settings['authors']['avatar']['provider']['rating'] ?? '')) ? null : $rating; - $default = empty($default = (string)($settings['authors']['avatar']['provider']['default'] ?? '')) ? null : $default; + $size = empty($size = (string)($settings['authors.']['avatar.']['provider.']['size'] ?? '')) ? null : (int)$size; + $rating = empty($rating = (string)($settings['authors.']['avatar.']['provider.']['rating'] ?? '')) ? null : $rating; + $default = empty($default = (string)($settings['authors.']['avatar.']['provider.']['default'] ?? '')) ? null : $default; $gravatarUri = $this->gravatarUriBuilder->getUri( $author->getEmail(), @@ -114,4 +115,9 @@ private function deriveFileTypeFromContentType(string $contentType): string { return substr($contentType, (int)strrpos($contentType, '/') + 1); } + + protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController + { + return $GLOBALS['TSFE']; + } } diff --git a/Classes/AvatarProvider/ImageProvider.php b/Classes/AvatarProvider/ImageProvider.php index 0d4eb15f..807512cb 100644 --- a/Classes/AvatarProvider/ImageProvider.php +++ b/Classes/AvatarProvider/ImageProvider.php @@ -14,10 +14,9 @@ use T3G\AgencyPack\Blog\Domain\Model\Author; use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Domain\Model\FileReference; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Service\ImageService; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class ImageProvider implements AvatarProviderInterface { @@ -26,13 +25,14 @@ public function getAvatarUrl(Author $author): string $image = $author->getImage(); if ($image instanceof FileReference) { $defaultSize = 32; - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - - $configurationManager = $objectManager->get(ConfigurationManagerInterface::class); - $settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); - $size = ($settings['authors']['avatar']['provider']['size'] ?? $defaultSize) ?: $defaultSize; + $settings = []; + $frontendController = self::getTypoScriptFrontendController(); + if ($frontendController instanceof TypoScriptFrontendController) { + $settings = $frontendController->tmpl->setup['plugin.']['tx_blog.']['settings.'] ?? []; + } + $size = ($settings['authors.']['avatar.']['provider.']['size'] ?? $defaultSize) ?: $defaultSize; - $imageService = $objectManager->get(ImageService::class); + $imageService = GeneralUtility::makeInstance(ImageService::class); $image = $imageService->getImage('', $image, false); if ($image->hasProperty('crop') && $image->getProperty('crop')) { @@ -53,4 +53,9 @@ public function getAvatarUrl(Author $author): string } return ''; } + + protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController + { + return $GLOBALS['TSFE']; + } } diff --git a/Classes/Controller/PostController.php b/Classes/Controller/PostController.php index c5b96a6e..2b07c6bb 100644 --- a/Classes/Controller/PostController.php +++ b/Classes/Controller/PostController.php @@ -27,7 +27,7 @@ use TYPO3\CMS\Core\Http\NormalizedParams; use TYPO3\CMS\Core\Site\Entity\SiteLanguage; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; +use TYPO3Fluid\Fluid\View\ViewInterface; use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; @@ -115,7 +115,6 @@ public function injectPostRepositoryDemandFactory(PostRepositoryDemandFactory $p */ protected function initializeView(ViewInterface $view): void { - parent::initializeView($view); if ($this->request->getFormat() === 'rss') { $action = '.' . $this->request->getControllerActionName(); $arguments = []; diff --git a/Classes/Domain/Factory/CommentFormFactory.php b/Classes/Domain/Factory/CommentFormFactory.php index 52b80a5b..5c8b556c 100644 --- a/Classes/Domain/Factory/CommentFormFactory.php +++ b/Classes/Domain/Factory/CommentFormFactory.php @@ -12,10 +12,9 @@ use T3G\AgencyPack\Blog\Domain\Finisher\CommentFormFinisher; use T3G\AgencyPack\Blog\Domain\Validator\GoogleCaptchaValidator; +use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Extbase\Validation\Validator\EmailAddressValidator; use TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator; @@ -29,6 +28,12 @@ class CommentFormFactory extends AbstractFormFactory { + protected TypoScriptService $typoScriptService; + + public function __construct(TypoScriptService $typoScriptService) + { + $this->typoScriptService = $typoScriptService; + } /** * Build a FormDefinition. * This example build a FormDefinition manually, @@ -41,8 +46,7 @@ class CommentFormFactory extends AbstractFormFactory public function build(array $configuration, string $prototypeName = null): FormDefinition { $prototypeName = 'standard'; - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $formConfigurationService = $objectManager->get(ConfigurationService::class); + $formConfigurationService = GeneralUtility::makeInstance(ConfigurationService::class); $prototypeConfiguration = $formConfigurationService->getPrototypeConfiguration($prototypeName); $prototypeConfiguration['formElementsDefinition']['BlogGoogleCaptcha'] = $prototypeConfiguration['formElementsDefinition']['BlogGoogleCaptcha'] ?? []; ArrayUtility::mergeRecursiveWithOverrule( @@ -52,14 +56,18 @@ public function build(array $configuration, string $prototypeName = null): FormD ] ); - $configurationManager = $objectManager->get(ConfigurationManagerInterface::class); - $blogSettings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); + $blogSettings = []; + $frontendController = $this->getTypoScriptFrontendController(); + if ($frontendController instanceof TypoScriptFrontendController) { + $settings = $frontendController->tmpl->setup['plugin.']['tx_blog.']['settings.'] ?? []; + $blogSettings = $this->typoScriptService->convertTypoScriptArrayToPlainArray($settings); + } $captcha = []; $captcha['enable'] = (bool) ($blogSettings['comments']['google_recaptcha']['_typoScriptNodeValue'] ?? false); $captcha['sitekey'] = (string) trim($blogSettings['comments']['google_recaptcha']['website_key'] ?? ''); $captcha['secret'] = (string) trim($blogSettings['comments']['google_recaptcha']['secret_key'] ?? ''); - $form = $objectManager->get(FormDefinition::class, 'postcomment', $prototypeConfiguration); + $form = GeneralUtility::makeInstance(FormDefinition::class, 'postcomment', $prototypeConfiguration); $form->setRenderingOption('controllerAction', 'form'); $form->setRenderingOption('submitButtonLabel', LocalizationUtility::translate('form.comment.submit', 'blog')); $renderingOptions = $form->getRenderingOptions(); @@ -71,23 +79,25 @@ public function build(array $configuration, string $prototypeName = null): FormD // Form $nameField = $page->createElement('name', 'Text'); $nameField->setLabel(LocalizationUtility::translate('form.comment.name', 'blog')); - $nameField->addValidator($objectManager->get(NotEmptyValidator::class)); + $nameField->addValidator(GeneralUtility::makeInstance(NotEmptyValidator::class)); $emailField = $page->createElement('email', 'Text'); $emailField->setLabel(LocalizationUtility::translate('form.comment.email', 'blog')); - $emailField->addValidator($objectManager->get(NotEmptyValidator::class)); - $emailField->addValidator($objectManager->get(EmailAddressValidator::class)); + $emailField->addValidator(GeneralUtility::makeInstance(NotEmptyValidator::class)); + $emailField->addValidator(GeneralUtility::makeInstance(EmailAddressValidator::class)); if ((bool) $blogSettings['comments']['features']['urls']) { $urlField = $page->createElement('url', 'Text'); $urlField->setLabel(LocalizationUtility::translate('form.comment.url', 'blog')); - $urlField->addValidator($objectManager->get(UrlValidator::class)); + $urlField->addValidator(GeneralUtility::makeInstance(UrlValidator::class)); } $commentField = $page->createElement('comment', 'Textarea'); $commentField->setLabel(LocalizationUtility::translate('form.comment.comment', 'blog')); - $commentField->addValidator($objectManager->get(NotEmptyValidator::class)); - $commentField->addValidator($objectManager->get(StringLengthValidator::class, ['minimum' => 5])); + $commentField->addValidator(GeneralUtility::makeInstance(NotEmptyValidator::class)); + $stringLengthValidator = GeneralUtility::makeInstance(StringLengthValidator::class); + $stringLengthValidator->setOptions(['minimum' => 5]); + $commentField->addValidator($stringLengthValidator); $explanationText = $page->createElement('explanation', 'StaticText'); $explanationText->setProperty('text', LocalizationUtility::translate('label.required.field', 'blog') . ' ' . LocalizationUtility::translate('label.required.field.explanation', 'blog')); @@ -95,17 +105,17 @@ public function build(array $configuration, string $prototypeName = null): FormD if ($captcha['enable'] && $captcha['sitekey'] && $captcha['secret']) { $captchaField = $page->createElement('captcha', 'BlogGoogleCaptcha'); $captchaField->setProperty('sitekey', $captcha['sitekey']); - $captchaField->addValidator($objectManager->get(GoogleCaptchaValidator::class)); + $captchaField->addValidator(GeneralUtility::makeInstance(GoogleCaptchaValidator::class)); } // Finisher - $commentFinisher = $objectManager->get(CommentFormFinisher::class); + $commentFinisher = GeneralUtility::makeInstance(CommentFormFinisher::class); if (method_exists($commentFinisher, 'setFinisherIdentifier')) { $commentFinisher->setFinisherIdentifier(CommentFormFinisher::class); } $form->addFinisher($commentFinisher); - $redirectFinisher = $objectManager->get(RedirectFinisher::class); + $redirectFinisher = GeneralUtility::makeInstance(RedirectFinisher::class); if (method_exists($redirectFinisher, 'setFinisherIdentifier')) { $redirectFinisher->setFinisherIdentifier(RedirectFinisher::class); } diff --git a/Classes/Domain/Finisher/CommentFormFinisher.php b/Classes/Domain/Finisher/CommentFormFinisher.php index c12d19ee..c11d89d1 100644 --- a/Classes/Domain/Finisher/CommentFormFinisher.php +++ b/Classes/Domain/Finisher/CommentFormFinisher.php @@ -17,10 +17,14 @@ use T3G\AgencyPack\Blog\Service\CacheService; use T3G\AgencyPack\Blog\Service\CommentService; use TYPO3\CMS\Core\Messaging\FlashMessage; +use TYPO3\CMS\Core\Messaging\FlashMessageService; +use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; +use TYPO3\CMS\Extbase\Service\ExtensionService; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; /** * This finisher redirects to another Controller. @@ -29,6 +33,45 @@ */ class CommentFormFinisher extends AbstractFinisher { + + protected FlashMessageService $flashMessageService; + protected PostRepository $postRepository; + protected CacheService $cacheService; + protected CommentService $commentService; + protected TypoScriptService $typoScriptService; + protected ExtensionService $extensionService; + + + public function injectFlashMessageService(FlashMessageService $flashMessageService): void + { + $this->flashMessageService = $flashMessageService; + } + + public function injectPostRepository(PostRepository $postRepository): void + { + $this->postRepository = $postRepository; + } + + public function injectCacheService(CacheService $cacheService): void + { + $this->cacheService = $cacheService; + } + + public function injectCommentService(CommentService $commentService): void + { + $this->commentService = $commentService; + } + + public function injectTypoScriptService(TypoScriptService $typoScriptService): void + { + $this->typoScriptService = $typoScriptService; + } + + public function injectExtensionService(ExtensionService $extensionService): void + { + $this->extensionService = $extensionService; + } + protected static $messages = [ CommentService::STATE_ERROR => [ 'title' => 'message.addComment.error.title', @@ -49,12 +92,13 @@ class CommentFormFinisher extends AbstractFinisher protected function executeInternal() { - $configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class); - $settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); - $postRepository = $this->objectManager->get(PostRepository::class); - $cacheService = $this->objectManager->get(CacheService::class); - $commentService = $this->objectManager->get(CommentService::class); - $commentService->injectSettings($settings['comments']); + $settings = []; + $frontendController = $this->getTypoScriptFrontendController(); + if ($frontendController instanceof TypoScriptFrontendController) { + $settings = $frontendController->tmpl->setup['plugin.']['tx_blog.']['settings.'] ?? []; + $settings = $this->typoScriptService->convertTypoScriptArrayToPlainArray($settings); + } + $this->commentService->injectSettings($settings['comments']); // Create Comment $values = $this->finisherContext->getFormValues(); @@ -63,27 +107,37 @@ protected function executeInternal() $comment->setEmail($values['email'] ?? ''); $comment->setUrl($values['url'] ?? ''); $comment->setComment($values['comment'] ?? ''); - $post = $postRepository->findCurrentPost(); - $state = $commentService->addComment($post, $comment); + $post = $this->postRepository->findCurrentPost(); + $state = $this->commentService->addComment($post, $comment); // Add FlashMessage - $flashMessage = $this->objectManager->get( + $pluginNamespace = $this->extensionService->getPluginNamespace( + $this->finisherContext->getRequest()->getControllerExtensionName(), + $this->finisherContext->getRequest()->getPluginName() + ); + $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, LocalizationUtility::translate(self::$messages[$state]['text'], 'blog'), LocalizationUtility::translate(self::$messages[$state]['title'], 'blog'), self::$messages[$state]['severity'], true ); - $this->finisherContext->getControllerContext()->getFlashMessageQueue()->addMessage($flashMessage); + $this->flashMessageService->getMessageQueueByIdentifier('extbase.flashmessages.' . $pluginNamespace)->addMessage($flashMessage); if ($state !== CommentService::STATE_ERROR) { $comment->setCrdate(new \DateTime()); + GeneralUtility::makeInstance(NotificationManager::class) ->notify(GeneralUtility::makeInstance(CommentAddedNotification::class, '', '', [ 'comment' => $comment, 'post' => $post, ])); - $cacheService->flushCacheByTag('tx_blog_post_' . $post->getUid()); + $this->cacheService->flushCacheByTag('tx_blog_post_' . $post->getUid()); } } + + protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController + { + return $GLOBALS['TSFE']; + } } diff --git a/Classes/Domain/Model/Comment.php b/Classes/Domain/Model/Comment.php index e6bfa011..56c85d47 100644 --- a/Classes/Domain/Model/Comment.php +++ b/Classes/Domain/Model/Comment.php @@ -10,7 +10,6 @@ namespace T3G\AgencyPack\Blog\Domain\Model; -use TYPO3\CMS\Extbase\Domain\Model\FrontendUser; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; class Comment extends AbstractEntity @@ -23,7 +22,7 @@ class Comment extends AbstractEntity /** * The author of the comment. * - * @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser + * @var FrontendUser */ protected $author; diff --git a/Classes/Domain/Model/FrontendUser.php b/Classes/Domain/Model/FrontendUser.php new file mode 100644 index 00000000..5f1445a2 --- /dev/null +++ b/Classes/Domain/Model/FrontendUser.php @@ -0,0 +1,39 @@ +name; + } + + public function setName(string $name): void + { + $this->name = $name; + } + + public function getEmail(): string + { + return $this->email; + } + + public function setEmail(string $email): void + { + $this->email = $email; + } +} diff --git a/Classes/Domain/Model/Post.php b/Classes/Domain/Model/Post.php index 536231eb..07a1e22f 100644 --- a/Classes/Domain/Model/Post.php +++ b/Classes/Domain/Model/Post.php @@ -17,7 +17,6 @@ use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; class Post extends AbstractEntity @@ -375,9 +374,7 @@ public function getComments(): ObjectStorage */ public function getActiveComments() { - return GeneralUtility::makeInstance(ObjectManager::class) - ->get(CommentRepository::class) - ->findAllByPost($this); + return (GeneralUtility::makeInstance(CommentRepository::class))->findAllByPost($this); } /** @@ -542,8 +539,7 @@ public function getCrdateYear(): int */ public function getUri(): string { - return GeneralUtility::makeInstance(ObjectManager::class) - ->get(UriBuilder::class) + return (GeneralUtility::makeInstance(UriBuilder::class)) ->setCreateAbsoluteUri(true) ->setTargetPageUid($this->getUid()) ->build(); diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index 387a48a2..b1d0a09b 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -10,6 +10,7 @@ namespace T3G\AgencyPack\Blog\Domain\Repository; +use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; @@ -19,6 +20,14 @@ class CategoryRepository extends Repository { + protected ConfigurationManagerInterface $configurationManager; + + public function __construct(ConfigurationManagerInterface $configurationManager) + { + parent::__construct(); + $this->configurationManager = $configurationManager; + } + /** * Initializes the repository. * @@ -28,9 +37,12 @@ public function initializeObject(): void { // @TODO: It looks like extbase ignore storage settings for sys_category. // @TODO: this hack set the storage handling for sys_category table. - $configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class); - $settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); - $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); + $querySettings = GeneralUtility::makeInstance( + Typo3QuerySettings::class, + GeneralUtility::makeInstance(Context::class), + $this->configurationManager + ); $querySettings->setRespectStoragePage(true); $querySettings->setStoragePageIds(GeneralUtility::trimExplode(',', $settings['storagePid'])); @@ -70,7 +82,7 @@ public function getByReference($table, $uid, $field = 'categories') $queryBuilder->expr()->eq('fieldname', $queryBuilder->createNamedParameter($field)), $queryBuilder->expr()->eq('uid_foreign', $queryBuilder->createNamedParameter($uid)) ); - $categories = array_column($queryBuilder->execute()->fetchAll(), 'uid_local'); + $categories = array_column($queryBuilder->execute()->fetchAllAssociative(), 'uid_local'); if (!empty($categories)) { $query = $this->createQuery(); @@ -82,9 +94,7 @@ public function getByReference($table, $uid, $field = 'categories') $conditions[] = $query->in('uid', $categories); return $query->matching( - $query->logicalAnd( - $conditions - ) + $query->logicalAnd(...$conditions) )->execute(); } diff --git a/Classes/Domain/Repository/CommentRepository.php b/Classes/Domain/Repository/CommentRepository.php index 4e8679ef..7b2c18df 100644 --- a/Classes/Domain/Repository/CommentRepository.php +++ b/Classes/Domain/Repository/CommentRepository.php @@ -23,25 +23,27 @@ class CommentRepository extends Repository { - /** - * @var ConfigurationManagerInterface - */ - protected $configurationManager; + protected ConfigurationManagerInterface $configurationManager; + protected array $settings = []; - /** - * @var array - */ - protected $settings; + public function __construct(ConfigurationManagerInterface $configurationManager) + { + parent::__construct(); + $this->configurationManager = $configurationManager; + } /** * @throws \InvalidArgumentException */ public function initializeObject(): void { - $this->configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class); $this->settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); - $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + $querySettings = GeneralUtility::makeInstance( + Typo3QuerySettings::class, + GeneralUtility::makeInstance(Context::class), + $this->configurationManager + ); // don't add the pid constraint $querySettings->setRespectStoragePage(false); $this->setDefaultQuerySettings($querySettings); @@ -63,7 +65,7 @@ public function findAllByPost(Post $post) $constraints = []; $constraints[] = $query->equals('post', $post->getUid()); $constraints = $this->fillConstraintsBySettings($query, $constraints); - return $query->matching($query->logicalAnd($constraints))->execute(); + return $query->matching($query->logicalAnd(...$constraints))->execute(); } /** @@ -75,7 +77,7 @@ public function findAllByPost(Post $post) public function findAllByFilter(string $filter = null, int $blogSetup = null) { $query = $this->createQuery(); - $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + $querySettings = $query->getQuerySettings(); $querySettings->setRespectStoragePage(false); $query->setQuerySettings($querySettings); @@ -103,7 +105,7 @@ public function findAllByFilter(string $filter = null, int $blogSetup = null) $constraints[] = $query->in('pid', $this->getPostPidsByRootPid($blogSetup)); } if (!empty($constraints)) { - return $query->matching($query->logicalAnd($constraints))->execute(); + return $query->matching($query->logicalAnd(...$constraints))->execute(); } return $this->findAll(); @@ -132,7 +134,7 @@ public function findActiveComments(int $limit = null, int $blogSetup = null) $constraints[] = $query->in('pid', $storagePids); } } - return $query->matching($query->logicalAnd($constraints))->execute(); + return $query->matching($query->logicalAnd(...$constraints))->execute(); } /** @@ -149,7 +151,7 @@ protected function getPostPidsByRootPid(int $blogRootPid): array ->where($queryBuilder->expr()->eq('doktype', Constants::DOKTYPE_BLOG_POST)) ->andWhere($queryBuilder->expr()->eq('pid', $blogRootPid)) ->execute() - ->fetchAll(); + ->fetchAllAssociative(); $result = []; foreach ($rows as $row) { $result[] = $row['uid']; @@ -181,27 +183,27 @@ public function fillConstraintsBySettings(QueryInterface $query, array $constrai : 0; if ($respectPostLanguageId) { /** @noinspection PhpUnhandledExceptionInspection */ - $constraints[] = $query->logicalOr([ + $constraints[] = $query->logicalOr( $query->equals('postLanguageId', GeneralUtility::makeInstance(Context::class)->getAspect('language')->getId()), $query->equals('postLanguageId', -1), - ]); + ); } $tstamp = time(); - $constraints[] = $query->logicalAnd([ - $query->logicalOr([ + $constraints[] = $query->logicalAnd( + $query->logicalOr( $query->equals('post.starttime', 0), $query->lessThanOrEqual('post.starttime', $tstamp) - ]), - $query->logicalOr([ + ), + $query->logicalOr( $query->equals('post.endtime', 0), $query->greaterThanOrEqual('post.endtime', $tstamp) - ]) - ]); - $constraints[] = $query->logicalAnd([ + ) + ); + $constraints[] = $query->logicalAnd( $query->equals('post.hidden', 0), $query->equals('post.deleted', 0) - ]); + ); return $constraints; } } diff --git a/Classes/Domain/Repository/PostRepository.php b/Classes/Domain/Repository/PostRepository.php index f23e1a55..e1c6a9a9 100644 --- a/Classes/Domain/Repository/PostRepository.php +++ b/Classes/Domain/Repository/PostRepository.php @@ -34,17 +34,25 @@ class PostRepository extends Repository { - /** - * @var array - */ - protected $defaultConstraints = []; + protected array $defaultConstraints = []; + protected ConfigurationManagerInterface $configurationManager; + + public function __construct(ConfigurationManagerInterface $configurationManager) + { + parent::__construct(); + $this->configurationManager = $configurationManager; + } /** * @throws \Exception */ public function initializeObject(): void { - $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + $querySettings = GeneralUtility::makeInstance( + Typo3QuerySettings::class, + GeneralUtility::makeInstance(Context::class), + $this->configurationManager + ); // don't add the pid constraint $querySettings->setRespectStoragePage(false); $this->setDefaultQuerySettings($querySettings); @@ -52,10 +60,10 @@ public function initializeObject(): void $this->defaultConstraints[] = $query->equals('doktype', Constants::DOKTYPE_BLOG_POST); if (GeneralUtility::makeInstance(Context::class)->getAspect('language')->getId() === 0) { - $this->defaultConstraints[] = $query->logicalOr([ + $this->defaultConstraints[] = $query->logicalOr( $query->equals('l18n_cfg', 0), $query->equals('l18n_cfg', 2) - ]); + ); } else { $this->defaultConstraints[] = $query->lessThan('l18n_cfg', 2); } @@ -100,14 +108,14 @@ public function findByRepositoryDemand(PostRepositoryDemand $repositoryDemand): $tagsConstraints[] = $query->equals('tags.uid', $tag->getUid()); } $tagsConjunction = $repositoryDemand->getTagsConjunction() === Constants::REPOSITORY_CONJUNCTION_AND ? 'logicalAnd' : 'logicalOr'; - $constraints[] = $query->{$tagsConjunction}($tagsConstraints); + $constraints[] = $query->{$tagsConjunction}(...$tagsConstraints); } if (($ordering = $repositoryDemand->getOrdering()) !== []) { $query->setOrderings([$ordering['field'] => $ordering['direction']]); } } - $query->matching($query->logicalAnd($constraints)); + $query->matching($query->logicalAnd(...$constraints)); if (($limit = $repositoryDemand->getLimit()) > 0) { $query->setLimit($limit); @@ -153,10 +161,10 @@ public function findAllByPid(int $blogSetup = null) if ($blogSetup !== null) { $existingConstraint = $query->getConstraint(); $additionalConstraint = $query->equals('pid', $blogSetup); - $query->matching($query->logicalAnd([ + $query->matching($query->logicalAnd( $existingConstraint, $additionalConstraint - ])); + )); } return $query->execute(); @@ -190,12 +198,12 @@ protected function getFindAllQuery(): QueryInterface if ($storagePidConstraint instanceof ComparisonInterface) { $constraints[] = $storagePidConstraint; } - $constraints[] = $query->logicalOr([ + $constraints[] = $query->logicalOr( $query->equals('archiveDate', 0), $query->greaterThanOrEqual('archiveDate', time()), - ]); + ); - $query->matching($query->logicalAnd($constraints)); + $query->matching($query->logicalAnd(...$constraints)); return $query; } @@ -216,7 +224,7 @@ public function findAllByAuthor(Author $author) } $constraints[] = $query->contains('authors', $author); - return $query->matching($query->logicalAnd($constraints))->execute(); + return $query->matching($query->logicalAnd(...$constraints))->execute(); } /** @@ -235,7 +243,7 @@ public function findAllByCategory(Category $category) $constraints[] = $storagePidConstraint; } - return $query->matching($query->logicalAnd($constraints))->execute(); + return $query->matching($query->logicalAnd(...$constraints))->execute(); } /** @@ -254,7 +262,7 @@ public function findAllByTag(Tag $tag) $constraints[] = $storagePidConstraint; } - return $query->matching($query->logicalAnd($constraints))->execute(); + return $query->matching($query->logicalAnd(...$constraints))->execute(); } /** @@ -284,7 +292,7 @@ public function findByMonthAndYear(int $year, int $month = null) $constraints[] = $query->greaterThanOrEqual('publish_date', $startDate->getTimestamp()); $constraints[] = $query->lessThanOrEqual('publish_date', $endDate->getTimestamp()); - return $query->matching($query->logicalAnd($constraints))->execute(); + return $query->matching($query->logicalAnd(...$constraints))->execute(); } /** @@ -324,7 +332,7 @@ protected function getPostWithLanguage(int $pageId, int $languageId): ?Post } return $query - ->matching($query->logicalAnd($constraints)) + ->matching($query->logicalAnd(...$constraints)) ->execute() ->getFirst(); } @@ -377,7 +385,7 @@ public function findMonthsAndYearsWithPosts(): array } $constraints[] = $query->greaterThan('crdateMonth', 0); $constraints[] = $query->greaterThan('crdateYear', 0); - $query->matching($query->logicalAnd($constraints)); + $query->matching($query->logicalAnd(...$constraints)); $posts = $query->execute(true); $result = []; @@ -475,8 +483,7 @@ public function findRelatedPosts(int $categoryMultiplier = 1, int $tagMultiplier */ protected function getStoragePidsFromTypoScript(): array { - $configurationManager = $this->objectManager->get(ConfigurationManager::class); - $settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); + $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); return GeneralUtility::intExplode(',', $settings['persistence']['storagePid']); } diff --git a/Classes/Domain/Repository/TagRepository.php b/Classes/Domain/Repository/TagRepository.php index 963e4129..eb27ab42 100644 --- a/Classes/Domain/Repository/TagRepository.php +++ b/Classes/Domain/Repository/TagRepository.php @@ -18,12 +18,14 @@ class TagRepository extends Repository { - /** - * Plugin settings - * - * @var array $pluginSettings - */ - protected $pluginSettings; + protected array $pluginSettings = []; + protected ConfigurationManagerInterface $configurationManager; + + public function __construct(ConfigurationManagerInterface $configurationManager) + { + parent::__construct(); + $this->configurationManager = $configurationManager; + } /** * Initializes the repository. @@ -36,9 +38,7 @@ public function initializeObject(): void 'title' => QueryInterface::ORDER_ASCENDING, ]; - /** @var ConfigurationManagerInterface $configurationManager */ - $configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class); - $this->pluginSettings = $configurationManager->getConfiguration( + $this->pluginSettings = $this->configurationManager->getConfiguration( ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS ); } @@ -81,7 +81,7 @@ public function findTopByUsage($limit = 20) $result = $queryBuilder ->execute() - ->fetchAll(); + ->fetchAllAssociative(); $rows = []; foreach ($result as $row) { diff --git a/Classes/Domain/Validator/GoogleCaptchaValidator.php b/Classes/Domain/Validator/GoogleCaptchaValidator.php index a2448a4e..d6a359bd 100644 --- a/Classes/Domain/Validator/GoogleCaptchaValidator.php +++ b/Classes/Domain/Validator/GoogleCaptchaValidator.php @@ -12,10 +12,10 @@ use T3G\AgencyPack\Blog\Domain\Model\Comment; use TYPO3\CMS\Core\Http\RequestFactory; +use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class GoogleCaptchaValidator extends AbstractValidator { @@ -25,9 +25,13 @@ public function isValid($value): void { $action = 'form'; $controller = 'Comment'; - $settings = GeneralUtility::makeInstance(ObjectManager::class) - ->get(ConfigurationManagerInterface::class) - ->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); + $settings = []; + $frontendController = $this->getTypoScriptFrontendController(); + if ($frontendController instanceof TypoScriptFrontendController) { + $settings = $frontendController->tmpl->setup['plugin.']['tx_blog.']['settings.'] ?? []; + $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class); + $settings = $typoScriptService->convertTypoScriptArrayToPlainArray($settings); + } $requestData = GeneralUtility::_GPmerged('tx_blog_commentform'); if ( @@ -60,4 +64,9 @@ public function isValid($value): void } } } + + protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController + { + return $GLOBALS['TSFE']; + } } diff --git a/Classes/Hooks/DataHandlerHook.php b/Classes/Hooks/DataHandlerHook.php index 26aeebf3..e2145a08 100644 --- a/Classes/Hooks/DataHandlerHook.php +++ b/Classes/Hooks/DataHandlerHook.php @@ -52,7 +52,7 @@ public function processDatamap_afterDatabaseOperations($status, $table, $id, arr ->from($table) ->where($queryBuilder->expr()->eq('uid', (int)$id)) ->execute() - ->fetch(); + ->fetchAssociative(); if (!empty($record)) { $timestamp = (int) (!empty($record['publish_date'] ?? 0) ? $record['publish_date'] : time()); $queryBuilder diff --git a/Classes/Mail/MailContent.php b/Classes/Mail/MailContent.php index a9238926..9b588160 100644 --- a/Classes/Mail/MailContent.php +++ b/Classes/Mail/MailContent.php @@ -10,10 +10,10 @@ namespace T3G\AgencyPack\Blog\Mail; +use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Fluid\View\StandaloneView; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class MailContent { @@ -48,17 +48,25 @@ public function render(string $template, array $arguments) : string */ protected function getFluidTemplateObject($template) : StandaloneView { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $settings = $objectManager - ->get(ConfigurationManagerInterface::class) - ->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'blog'); $view = GeneralUtility::makeInstance(StandaloneView::class); - $view->setLayoutRootPaths($settings['view']['emails']['layoutRootPaths']); - $view->setPartialRootPaths($settings['view']['emails']['partialRootPaths']); - $view->setTemplateRootPaths($settings['view']['emails']['templateRootPaths']); + $settings = []; + $frontendController = $this->getTypoScriptFrontendController(); + if ($frontendController instanceof TypoScriptFrontendController) { + $settings = $frontendController->tmpl->setup['plugin.']['tx_blog.'] ?? []; + $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class); + $settings = $typoScriptService->convertTypoScriptArrayToPlainArray($settings); + } + + $view->setLayoutRootPaths($settings['view']['emails']['layoutRootPaths'] ?? []); + $view->setPartialRootPaths($settings['view']['emails']['partialRootPaths'] ?? []); + $view->setTemplateRootPaths($settings['view']['emails']['templateRootPaths'] ?? []); $view->setTemplate($template); - $view->getRequest()->setControllerExtensionName('blog'); return $view; } + + protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController + { + return $GLOBALS['TSFE']; + } } diff --git a/Classes/Notification/Processor/AdminNotificationProcessor.php b/Classes/Notification/Processor/AdminNotificationProcessor.php index 221ca190..d11fa1cf 100644 --- a/Classes/Notification/Processor/AdminNotificationProcessor.php +++ b/Classes/Notification/Processor/AdminNotificationProcessor.php @@ -13,12 +13,13 @@ use T3G\AgencyPack\Blog\Mail\MailMessage; use T3G\AgencyPack\Blog\Notification\CommentAddedNotification; use T3G\AgencyPack\Blog\Notification\NotificationInterface; +use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class AdminNotificationProcessor implements ProcessorInterface { + /** * Process the notification * @@ -41,9 +42,13 @@ public function process(NotificationInterface $notification) protected function processCommentAddNotification(NotificationInterface $notification): void { $notificationId = $notification->getNotificationId(); - $settings = GeneralUtility::makeInstance(ObjectManager::class) - ->get(ConfigurationManagerInterface::class) - ->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); + $settings = []; + $frontendController = $this->getTypoScriptFrontendController(); + if ($frontendController instanceof TypoScriptFrontendController) { + $settings = $frontendController->tmpl->setup['plugin.']['tx_blog.']['settings.'] ?? []; + $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class); + $settings = $typoScriptService->convertTypoScriptArrayToPlainArray($settings); + } if ((int)$settings['notifications'][$notificationId]['admin']['_typoScriptNodeValue'] === 1) { $emailAddresses = GeneralUtility::trimExplode(',', $settings['notifications'][$notificationId]['admin']['email']); @@ -56,4 +61,9 @@ protected function processCommentAddNotification(NotificationInterface $notifica ->send(); } } + + protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController + { + return $GLOBALS['TSFE']; + } } diff --git a/Classes/Notification/Processor/AuthorNotificationProcessor.php b/Classes/Notification/Processor/AuthorNotificationProcessor.php index 41d3744a..f69df131 100644 --- a/Classes/Notification/Processor/AuthorNotificationProcessor.php +++ b/Classes/Notification/Processor/AuthorNotificationProcessor.php @@ -15,9 +15,9 @@ use T3G\AgencyPack\Blog\Mail\MailMessage; use T3G\AgencyPack\Blog\Notification\CommentAddedNotification; use T3G\AgencyPack\Blog\Notification\NotificationInterface; +use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class AuthorNotificationProcessor implements ProcessorInterface { @@ -45,9 +45,13 @@ protected function processCommentAddNotification(NotificationInterface $notifica { $notificationId = $notification->getNotificationId(); - $settings = GeneralUtility::makeInstance(ObjectManager::class) - ->get(ConfigurationManagerInterface::class) - ->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog'); + $settings = []; + $frontendController = $this->getTypoScriptFrontendController(); + if ($frontendController instanceof TypoScriptFrontendController) { + $settings = $frontendController->tmpl->setup['plugin.']['tx_blog.']['settings.'] ?? []; + $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class); + $settings = $typoScriptService->convertTypoScriptArrayToPlainArray($settings); + } /** @var Post $post */ $post = $notification->getData()['post']; @@ -64,4 +68,9 @@ protected function processCommentAddNotification(NotificationInterface $notifica } } } + + protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController + { + return $GLOBALS['TSFE']; + } } diff --git a/Classes/Routing/Aspect/StaticDatabaseMapper.php b/Classes/Routing/Aspect/StaticDatabaseMapper.php index 7f85c4d5..12cd8660 100644 --- a/Classes/Routing/Aspect/StaticDatabaseMapper.php +++ b/Classes/Routing/Aspect/StaticDatabaseMapper.php @@ -145,6 +145,6 @@ protected function buildValues(): array } } - return array_map('strval', array_column($queryBuilder->execute()->fetchAll(), $this->field)); + return array_map('strval', array_column($queryBuilder->execute()->fetchAllAssociative(), $this->field)); } } diff --git a/Classes/Service/CommentService.php b/Classes/Service/CommentService.php index ed97f91d..31481871 100644 --- a/Classes/Service/CommentService.php +++ b/Classes/Service/CommentService.php @@ -135,10 +135,10 @@ protected function approvedCommentExistsForSameEmail(Comment $comment): bool { $query = $this->commentRepository->createQuery(); return $query->matching( - $query->logicalAnd([ + $query->logicalAnd( $query->equals('email', $comment->getEmail()), $query->equals('status', Comment::STATUS_APPROVED) - ]) + ) )->execute()->count() > 0; } diff --git a/Classes/Service/SetupService.php b/Classes/Service/SetupService.php index bc9e913b..2f2bd80e 100644 --- a/Classes/Service/SetupService.php +++ b/Classes/Service/SetupService.php @@ -36,7 +36,7 @@ public function determineBlogSetups(): array ->where($queryBuilder->expr()->eq('doktype', $queryBuilder->createNamedParameter(Constants::DOKTYPE_BLOG_POST, \PDO::PARAM_INT))) ->groupBy('pid') ->execute() - ->fetchAll(); + ->fetchAllAssociative(); foreach ($blogRootPages as $blogRootPage) { $blogUid = $blogRootPage['pid']; if (!array_key_exists($blogUid, $setups)) { @@ -91,7 +91,7 @@ public function createBlogSetup(array $data): bool ->from('pages') ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($blogRootUid, \PDO::PARAM_INT))) ->execute() - ->fetch(); + ->fetchAssociative(); $queryBuilder->update('pages') ->set('TSconfig', str_replace('NEW_blogFolder', $blogFolderUid, $record['TSconfig'])) ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($blogRootUid, \PDO::PARAM_INT))) @@ -120,7 +120,7 @@ public function createBlogSetup(array $data): bool ->from('sys_template') ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($sysTemplateUid, \PDO::PARAM_INT))) ->execute() - ->fetch(); + ->fetchAssociative(); $queryBuilder ->update('sys_template') ->set('constants', str_replace( diff --git a/Classes/Updates/AuthorSlugUpdate.php b/Classes/Updates/AuthorSlugUpdate.php index 12653629..0d0f78a9 100644 --- a/Classes/Updates/AuthorSlugUpdate.php +++ b/Classes/Updates/AuthorSlugUpdate.php @@ -115,7 +115,7 @@ public function executeUpdate(): bool $hasToBeUniqueInPid = in_array('uniqueInPid', $evalInfo, true); $slugHelper = GeneralUtility::makeInstance(SlugHelper::class, $this->table, $this->slugField, $fieldConfig); - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $recordId = (int)$record['uid']; $pid = (int)$record['pid']; diff --git a/Classes/Updates/AvatarProviderUpdate.php b/Classes/Updates/AvatarProviderUpdate.php index 2bf95d21..28124b0e 100644 --- a/Classes/Updates/AvatarProviderUpdate.php +++ b/Classes/Updates/AvatarProviderUpdate.php @@ -69,7 +69,7 @@ public function executeUpdate(): bool $queryBuilder->expr()->eq('avatar_provider', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)) ) ->execute(); - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $queryBuilder = $connection->createQueryBuilder(); $queryBuilder->update('tx_blog_domain_model_author') ->where( diff --git a/Classes/Updates/CategorySlugUpdate.php b/Classes/Updates/CategorySlugUpdate.php index 9950ec05..37d18b1d 100644 --- a/Classes/Updates/CategorySlugUpdate.php +++ b/Classes/Updates/CategorySlugUpdate.php @@ -118,7 +118,7 @@ public function executeUpdate(): bool $hasToBeUniqueInPid = in_array('uniqueInPid', $evalInfo, true); $slugHelper = GeneralUtility::makeInstance(SlugHelper::class, $this->table, $this->slugField, $fieldConfig); - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $recordId = (int)$record['uid']; $pid = (int)$record['pid']; @@ -131,7 +131,7 @@ public function executeUpdate(): bool ->from($this->table) ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['t3ver_oid'], \PDO::PARAM_INT)) - )->execute()->fetch(); + )->execute()->fetchAssociative(); $pid = (int)$liveVersion['pid']; } diff --git a/Classes/Updates/CategoryTypeUpdate.php b/Classes/Updates/CategoryTypeUpdate.php index 3442c705..2316f51d 100644 --- a/Classes/Updates/CategoryTypeUpdate.php +++ b/Classes/Updates/CategoryTypeUpdate.php @@ -75,7 +75,7 @@ public function updateNecessary(): bool ) ->execute(); $pages = []; - while ($pageRecord = $pagesStatement->fetch()) { + while ($pageRecord = $pagesStatement->fetchAssociative()) { $pages[] = $pageRecord['uid']; } @@ -114,7 +114,7 @@ public function executeUpdate(): bool ) ->execute(); $pages = []; - while ($pageRecord = $pagesStatement->fetch()) { + while ($pageRecord = $pagesStatement->fetchAssociative()) { $pages[] = $pageRecord['uid']; } @@ -131,7 +131,7 @@ public function executeUpdate(): bool ) ->execute(); - while ($categoryRecord = $categoryStatement->fetch()) { + while ($categoryRecord = $categoryStatement->fetchAssociative()) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_category'); $queryBuilder ->update('sys_category') diff --git a/Classes/Updates/DatabaseMonthYearUpdate.php b/Classes/Updates/DatabaseMonthYearUpdate.php index 92fdf850..01d5fa07 100644 --- a/Classes/Updates/DatabaseMonthYearUpdate.php +++ b/Classes/Updates/DatabaseMonthYearUpdate.php @@ -79,7 +79,7 @@ public function executeUpdate(): bool ) ) ->execute(); - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $timestamp = $record['crdate'] ?? time(); $queryBuilder = $connection->createQueryBuilder(); $queryBuilder->update('pages') diff --git a/Classes/Updates/DatabasePublishDateUpdate.php b/Classes/Updates/DatabasePublishDateUpdate.php index aaa5dc84..c020afcd 100644 --- a/Classes/Updates/DatabasePublishDateUpdate.php +++ b/Classes/Updates/DatabasePublishDateUpdate.php @@ -78,7 +78,7 @@ public function executeUpdate(): bool ) ) ->execute(); - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $timestamp = $record['crdate'] ?? time(); $queryBuilder = $connection->createQueryBuilder(); $queryBuilder->update('pages') diff --git a/Classes/Updates/FeaturedImageUpdate.php b/Classes/Updates/FeaturedImageUpdate.php index 155997dd..a0b99743 100644 --- a/Classes/Updates/FeaturedImageUpdate.php +++ b/Classes/Updates/FeaturedImageUpdate.php @@ -90,7 +90,7 @@ protected function getEgliablePages(): array ->execute(); $records = []; - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $records[$record['uid']] = $record; } @@ -116,7 +116,7 @@ protected function getEgliableFileReferences(): array ->execute(); $records = []; - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $records[$record['uid']] = $record; } diff --git a/Classes/Updates/TagSlugUpdate.php b/Classes/Updates/TagSlugUpdate.php index 2d72efb7..6e828cfa 100644 --- a/Classes/Updates/TagSlugUpdate.php +++ b/Classes/Updates/TagSlugUpdate.php @@ -115,7 +115,7 @@ public function executeUpdate(): bool $hasToBeUniqueInPid = in_array('uniqueInPid', $evalInfo, true); $slugHelper = GeneralUtility::makeInstance(SlugHelper::class, $this->table, $this->slugField, $fieldConfig); - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $recordId = (int)$record['uid']; $pid = (int)$record['pid']; diff --git a/Classes/ViewHelpers/Data/ContentListOptionsViewHelper.php b/Classes/ViewHelpers/Data/ContentListOptionsViewHelper.php index a4083ca4..f400f990 100644 --- a/Classes/ViewHelpers/Data/ContentListOptionsViewHelper.php +++ b/Classes/ViewHelpers/Data/ContentListOptionsViewHelper.php @@ -11,9 +11,9 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Data; use T3G\AgencyPack\Blog\Constants; +use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic; @@ -38,10 +38,13 @@ public function initializeArguments() */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $settings = $objectManager - ->get(ConfigurationManagerInterface::class) - ->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'blog'); + $settings = []; + $frontendController = self::getTypoScriptFrontendController(); + if ($frontendController instanceof TypoScriptFrontendController) { + $settings = $frontendController->tmpl->setup['plugin.']['tx_blog.'] ?? []; + $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class); + $settings = $typoScriptService->convertTypoScriptArrayToPlainArray($settings); + } $listTypeConfiguration = $settings['settings']['contentListOptions'][$arguments['listType']] ?? []; $data = array_merge( $listTypeConfiguration, @@ -59,4 +62,9 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl $variableProvider->remove($arguments['as']); $variableProvider->add($arguments['as'], $data); } + + protected static function getTypoScriptFrontendController(): ?TypoScriptFrontendController + { + return $GLOBALS['TSFE']; + } } diff --git a/Classes/ViewHelpers/Link/ArchiveViewHelper.php b/Classes/ViewHelpers/Link/ArchiveViewHelper.php index f72a2133..78b85be9 100644 --- a/Classes/ViewHelpers/Link/ArchiveViewHelper.php +++ b/Classes/ViewHelpers/Link/ArchiveViewHelper.php @@ -10,6 +10,8 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class ArchiveViewHelper extends AbstractTagBasedViewHelper @@ -53,7 +55,7 @@ public function render(): string if ($month > 0) { $arguments['month'] = $month; } - $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder(); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->reset() ->setTargetPageUid($pageUid); if ($rssFormat) { diff --git a/Classes/ViewHelpers/Link/AuthorViewHelper.php b/Classes/ViewHelpers/Link/AuthorViewHelper.php index c092412d..7792e8cd 100644 --- a/Classes/ViewHelpers/Link/AuthorViewHelper.php +++ b/Classes/ViewHelpers/Link/AuthorViewHelper.php @@ -11,6 +11,7 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link; use T3G\AgencyPack\Blog\Domain\Model\Author; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; @@ -89,7 +90,7 @@ protected function buildUriFromDefaultPage(Author $author, bool $rssFormat) protected function getUriBuilder(int $pageUid, array $additionalParams, bool $rssFormat): UriBuilder { /** @var UriBuilder $uriBuilder */ - $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder(); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->reset() ->setTargetPageUid($pageUid) ->setArguments($additionalParams); diff --git a/Classes/ViewHelpers/Link/CategoryViewHelper.php b/Classes/ViewHelpers/Link/CategoryViewHelper.php index 3613b537..5c4f1cfd 100644 --- a/Classes/ViewHelpers/Link/CategoryViewHelper.php +++ b/Classes/ViewHelpers/Link/CategoryViewHelper.php @@ -11,6 +11,8 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link; use T3G\AgencyPack\Blog\Domain\Model\Category; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class CategoryViewHelper extends AbstractTagBasedViewHelper @@ -50,7 +52,7 @@ public function render(): string $arguments = [ 'category' => $category->getUid(), ]; - $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder(); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->reset() ->setTargetPageUid($pageUid); if ($rssFormat) { diff --git a/Classes/ViewHelpers/Link/PostViewHelper.php b/Classes/ViewHelpers/Link/PostViewHelper.php index 0c3c5885..adba1eb3 100644 --- a/Classes/ViewHelpers/Link/PostViewHelper.php +++ b/Classes/ViewHelpers/Link/PostViewHelper.php @@ -11,6 +11,8 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link; use T3G\AgencyPack\Blog\Domain\Model\Post; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class PostViewHelper extends AbstractTagBasedViewHelper @@ -50,7 +52,7 @@ public function render(): string $post = $this->arguments['post']; $section = $this->arguments['section'] ?: ''; $pageUid = (int) $post->getUid(); - $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder(); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $createAbsoluteUri = (bool)$this->arguments['createAbsoluteUri']; $uri = $uriBuilder->reset() ->setTargetPageUid($pageUid) diff --git a/Classes/ViewHelpers/Link/TagViewHelper.php b/Classes/ViewHelpers/Link/TagViewHelper.php index 5978b3f0..3950f023 100644 --- a/Classes/ViewHelpers/Link/TagViewHelper.php +++ b/Classes/ViewHelpers/Link/TagViewHelper.php @@ -11,6 +11,8 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link; use T3G\AgencyPack\Blog\Domain\Model\Tag; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class TagViewHelper extends AbstractTagBasedViewHelper @@ -50,7 +52,7 @@ public function render(): string $arguments = [ 'tag' => $tag->getUid(), ]; - $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder(); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->reset() ->setTargetPageUid($pageUid); if ($rssFormat) { diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php index ef7ade7b..e83e1423 100644 --- a/Configuration/Extbase/Persistence/Classes.php +++ b/Configuration/Extbase/Persistence/Classes.php @@ -18,6 +18,9 @@ \T3G\AgencyPack\Blog\Domain\Model\Category::class => [ 'tableName' => 'sys_category', ], + \T3G\AgencyPack\Blog\Domain\Model\FrontendUser::class => [ + 'tableName' => 'fe_users', + ], \T3G\AgencyPack\Blog\Domain\Model\Comment::class => [ 'tableName' => 'tx_blog_domain_model_comment', 'properties' => [ diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 2844fc07..e853a7ce 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -6,3 +6,9 @@ services: T3G\AgencyPack\Blog\: resource: '../Classes/*' + + T3G\AgencyPack\Blog\Domain\Factory\CommentFormFactory: + public: true + + T3G\AgencyPack\Blog\Notification\Processor: + public: true diff --git a/ext_typoscript_setup.txt b/ext_typoscript_setup.txt index aea07bf9..46f75933 100644 --- a/ext_typoscript_setup.txt +++ b/ext_typoscript_setup.txt @@ -3,42 +3,3 @@ plugin.tx_blog { storagePid = {$plugin.tx_blog.settings.storagePid} } } - -config.tx_extbase.persistence { - classes { - T3G\AgencyPack\Blog\Domain\Model\Content { - mapping { - tableName = tt_content - } - } - T3G\AgencyPack\Blog\Domain\Model\Post { - mapping { - tableName = pages - } - } - T3G\AgencyPack\Blog\Domain\Model\Category { - mapping { - tableName = sys_category - } - } - T3G\AgencyPack\Blog\Domain\Model\Comment { - newRecordStoragePid = {$plugin.tx_blog.settings.storagePid} - mapping { - tableName = tx_blog_domain_model_comment - columns.parentid.mapOnProperty = post - } - } - T3G\AgencyPack\Blog\Domain\Model\Tag { - newRecordStoragePid = {$plugin.tx_blog.settings.storagePid} - mapping { - tableName = tx_blog_domain_model_tag - } - } - T3G\AgencyPack\Blog\Domain\Model\Author { - newRecordStoragePid = {$plugin.tx_blog.settings.storagePid} - mapping { - tableName = tx_blog_domain_model_author - } - } - } -} From e755e498453b6225657a16767c9ad80496e0d9d8 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Tue, 6 Dec 2022 13:41:45 +0100 Subject: [PATCH 04/13] [TASK] v11 compatibility --- Classes/Controller/PostController.php | 4 ++-- Classes/Domain/Factory/CommentFormFactory.php | 9 +++++++-- Classes/Domain/Repository/CategoryRepository.php | 3 +-- Classes/Domain/Repository/CommentRepository.php | 3 +-- Classes/Domain/Repository/PostRepository.php | 3 +-- Classes/Domain/Repository/TagRepository.php | 3 +-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Classes/Controller/PostController.php b/Classes/Controller/PostController.php index 2b07c6bb..e69878aa 100644 --- a/Classes/Controller/PostController.php +++ b/Classes/Controller/PostController.php @@ -111,9 +111,9 @@ public function injectPostRepositoryDemandFactory(PostRepositoryDemandFactory $p } /** - * @param ViewInterface $view + * @param ViewInterface|\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view */ - protected function initializeView(ViewInterface $view): void + protected function initializeView($view): void { if ($this->request->getFormat() === 'rss') { $action = '.' . $this->request->getControllerActionName(); diff --git a/Classes/Domain/Factory/CommentFormFactory.php b/Classes/Domain/Factory/CommentFormFactory.php index 5c8b556c..b8bfa7d0 100644 --- a/Classes/Domain/Factory/CommentFormFactory.php +++ b/Classes/Domain/Factory/CommentFormFactory.php @@ -12,6 +12,7 @@ use T3G\AgencyPack\Blog\Domain\Finisher\CommentFormFinisher; use T3G\AgencyPack\Blog\Domain\Validator\GoogleCaptchaValidator; +use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -95,8 +96,12 @@ public function build(array $configuration, string $prototypeName = null): FormD $commentField = $page->createElement('comment', 'Textarea'); $commentField->setLabel(LocalizationUtility::translate('form.comment.comment', 'blog')); $commentField->addValidator(GeneralUtility::makeInstance(NotEmptyValidator::class)); - $stringLengthValidator = GeneralUtility::makeInstance(StringLengthValidator::class); - $stringLengthValidator->setOptions(['minimum' => 5]); + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) { + $stringLengthValidator = GeneralUtility::makeInstance(StringLengthValidator::class, ['minimum' => 5]); + } else { + $stringLengthValidator = GeneralUtility::makeInstance(StringLengthValidator::class); + $stringLengthValidator->setOptions(['minimum' => 5]); + } $commentField->addValidator($stringLengthValidator); $explanationText = $page->createElement('explanation', 'StaticText'); diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index b1d0a09b..97a4312f 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -22,9 +22,8 @@ class CategoryRepository extends Repository { protected ConfigurationManagerInterface $configurationManager; - public function __construct(ConfigurationManagerInterface $configurationManager) + public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void { - parent::__construct(); $this->configurationManager = $configurationManager; } diff --git a/Classes/Domain/Repository/CommentRepository.php b/Classes/Domain/Repository/CommentRepository.php index 7b2c18df..4be41a22 100644 --- a/Classes/Domain/Repository/CommentRepository.php +++ b/Classes/Domain/Repository/CommentRepository.php @@ -26,9 +26,8 @@ class CommentRepository extends Repository protected ConfigurationManagerInterface $configurationManager; protected array $settings = []; - public function __construct(ConfigurationManagerInterface $configurationManager) + public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void { - parent::__construct(); $this->configurationManager = $configurationManager; } diff --git a/Classes/Domain/Repository/PostRepository.php b/Classes/Domain/Repository/PostRepository.php index e1c6a9a9..0df972d3 100644 --- a/Classes/Domain/Repository/PostRepository.php +++ b/Classes/Domain/Repository/PostRepository.php @@ -37,9 +37,8 @@ class PostRepository extends Repository protected array $defaultConstraints = []; protected ConfigurationManagerInterface $configurationManager; - public function __construct(ConfigurationManagerInterface $configurationManager) + public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void { - parent::__construct(); $this->configurationManager = $configurationManager; } diff --git a/Classes/Domain/Repository/TagRepository.php b/Classes/Domain/Repository/TagRepository.php index eb27ab42..433e32fd 100644 --- a/Classes/Domain/Repository/TagRepository.php +++ b/Classes/Domain/Repository/TagRepository.php @@ -21,9 +21,8 @@ class TagRepository extends Repository protected array $pluginSettings = []; protected ConfigurationManagerInterface $configurationManager; - public function __construct(ConfigurationManagerInterface $configurationManager) + public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void { - parent::__construct(); $this->configurationManager = $configurationManager; } From 7b9cbb846e2f0441951153a6dee2deecdc15a05d Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Tue, 6 Dec 2022 14:54:58 +0100 Subject: [PATCH 05/13] [TASK] PageLayout and RecordList Events --- .../View/BlogPostHeaderContentRenderer.php | 65 +++++++++++++++++++ Classes/Hooks/PageLayoutHeaderHook.php | 46 +++---------- Classes/Listener/ModifyPageLayoutContent.php | 39 +++++++++++ .../RenderAdditionalContentToRecordList.php | 39 +++++++++++ ...RenderAdditionalContentToRecordListV11.php | 39 +++++++++++ .../ViewHelpers/Link/Be/PostViewHelper.php | 3 +- Configuration/Services.yaml | 16 ++++- .../Private/Templates/PageLayout/Header.html | 4 +- ext_localconf.php | 7 +- 9 files changed, 214 insertions(+), 44 deletions(-) create mode 100644 Classes/Backend/View/BlogPostHeaderContentRenderer.php create mode 100644 Classes/Listener/ModifyPageLayoutContent.php create mode 100644 Classes/Listener/RenderAdditionalContentToRecordList.php create mode 100644 Classes/Listener/RenderAdditionalContentToRecordListV11.php diff --git a/Classes/Backend/View/BlogPostHeaderContentRenderer.php b/Classes/Backend/View/BlogPostHeaderContentRenderer.php new file mode 100644 index 00000000..e231528b --- /dev/null +++ b/Classes/Backend/View/BlogPostHeaderContentRenderer.php @@ -0,0 +1,65 @@ +postRepository = $postRepository; + } + + public function render(ServerRequestInterface $request): string + { + $pageUid = (int)($request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0); + $pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)); + + // Early exit for non-blog pages + if (($pageInfo['doktype'] ?? 0) !== Constants::DOKTYPE_BLOG_POST) { + return ''; + } + + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); + $pageRenderer->addCssFile('EXT:blog/Resources/Public/Css/pagelayout.min.css', 'stylesheet', 'all', '', false); + + + $query = $this->postRepository->createQuery(); + $querySettings = $query->getQuerySettings(); + $querySettings->setIgnoreEnableFields(true); + $this->postRepository->setDefaultQuerySettings($querySettings); + $post = $this->postRepository->findByUidRespectQuerySettings($pageUid); + + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->getRenderingContext()->getTemplatePaths()->fillDefaultsByPackageName('blog'); + $view->setTemplate('PageLayout/Header'); + $view->assignMultiple([ + 'pageUid' => $pageUid, + 'pageInfo' => $pageInfo, + 'post' => $post, + ]); + + $content = $view->render(); + return $content; + } +} diff --git a/Classes/Hooks/PageLayoutHeaderHook.php b/Classes/Hooks/PageLayoutHeaderHook.php index b85c61f6..bddc75ef 100644 --- a/Classes/Hooks/PageLayoutHeaderHook.php +++ b/Classes/Hooks/PageLayoutHeaderHook.php @@ -10,51 +10,23 @@ namespace T3G\AgencyPack\Blog\Hooks; -use T3G\AgencyPack\Blog\Constants; -use T3G\AgencyPack\Blog\Domain\Repository\PostRepository; -use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Core\Page\PageRenderer; -use TYPO3\CMS\Core\Type\Bitmask\Permission; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; -use TYPO3\CMS\Fluid\View\StandaloneView; +use T3G\AgencyPack\Blog\Backend\View\BlogPostHeaderContentRenderer; class PageLayoutHeaderHook { + protected BlogPostHeaderContentRenderer $blogPostHeaderContentRenderer; + + public function __construct(BlogPostHeaderContentRenderer $blogPostHeaderContentRenderer) + { + $this->blogPostHeaderContentRenderer = $blogPostHeaderContentRenderer; + } + /** * @return string */ public function drawHeader() { $request = $GLOBALS['TYPO3_REQUEST']; - $pageUid = (int)($request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0); - $pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)); - - // Early exit for non-blog pages - if (($pageInfo['doktype'] ?? 0) !== Constants::DOKTYPE_BLOG_POST) { - return ''; - } - - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->addCssFile('EXT:blog/Resources/Public/Css/pagelayout.min.css', 'stylesheet', 'all', '', false); - - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $repository = $objectManager->get(PostRepository::class); - $query = $repository->createQuery(); - $querySettings = $query->getQuerySettings(); - $querySettings->setIgnoreEnableFields(true); - $repository->setDefaultQuerySettings($querySettings); - $post = $repository->findByUidRespectQuerySettings($pageUid); - - $view = GeneralUtility::makeInstance(StandaloneView::class); - $view->getRenderingContext()->getTemplatePaths()->fillDefaultsByPackageName('blog'); - $view->setTemplate('PageLayout/Header'); - $view->assignMultiple([ - 'pageUid' => $pageUid, - 'pageInfo' => $pageInfo, - 'post' => $post, - ]); - - return $view->render(); + return $this->blogPostHeaderContentRenderer->render($request); } } diff --git a/Classes/Listener/ModifyPageLayoutContent.php b/Classes/Listener/ModifyPageLayoutContent.php new file mode 100644 index 00000000..491aac88 --- /dev/null +++ b/Classes/Listener/ModifyPageLayoutContent.php @@ -0,0 +1,39 @@ +blogPostHeaderContentRenderer = $blogPostHeaderContentRenderer; + } + + public function __invoke(ModifyPageLayoutContentEvent $e) + { + $extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class); + $blogConfiguration = $extensionConfiguration->get('blog'); + if ((bool)($blogConfiguration['disablePageLayoutHeader']) ?? true) { + return; + } + $request = $e->getRequest(); + $content = $this->blogPostHeaderContentRenderer->render($request); + $e->addHeaderContent($content); + } +} diff --git a/Classes/Listener/RenderAdditionalContentToRecordList.php b/Classes/Listener/RenderAdditionalContentToRecordList.php new file mode 100644 index 00000000..6302c0b8 --- /dev/null +++ b/Classes/Listener/RenderAdditionalContentToRecordList.php @@ -0,0 +1,39 @@ +blogPostHeaderContentRenderer = $blogPostHeaderContentRenderer; + } + + public function __invoke(RenderAdditionalContentToRecordListEvent $e) + { + $extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class); + $blogConfiguration = $extensionConfiguration->get('blog'); + if ((bool)($blogConfiguration['disablePageLayoutHeader']) ?? true) { + return; + } + $request = $e->getRequest(); + $content = $this->blogPostHeaderContentRenderer->render($request); + $e->addContentAbove($content); + } +} diff --git a/Classes/Listener/RenderAdditionalContentToRecordListV11.php b/Classes/Listener/RenderAdditionalContentToRecordListV11.php new file mode 100644 index 00000000..70eec319 --- /dev/null +++ b/Classes/Listener/RenderAdditionalContentToRecordListV11.php @@ -0,0 +1,39 @@ +blogPostHeaderContentRenderer = $blogPostHeaderContentRenderer; + } + + public function __invoke(RenderAdditionalContentToRecordListEvent $e) + { + $extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class); + $blogConfiguration = $extensionConfiguration->get('blog'); + if ((bool)($blogConfiguration['disablePageLayoutHeader']) ?? true) { + return; + } + $request = $e->getRequest(); + $content = $this->blogPostHeaderContentRenderer->render($request); + $e->addContentAbove($content); + } +} diff --git a/Classes/ViewHelpers/Link/Be/PostViewHelper.php b/Classes/ViewHelpers/Link/Be/PostViewHelper.php index e394198e..4a8ebde9 100644 --- a/Classes/ViewHelpers/Link/Be/PostViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/PostViewHelper.php @@ -57,15 +57,16 @@ public function render(): string switch ($this->arguments['action']) { case 'edit': $uri = (string)$uriBuilder->buildUriFromRoute('record_edit', ['edit[pages][' . $pageUid . ']' => 'edit']); + $route = '/module/web/list'; break; case 'show': default: $uri = (string)$uriBuilder->buildUriFromRoute('web_layout', ['id' => $pageUid]); + $route = '/module/web/layout'; break; } $arguments = GeneralUtility::_GET(); - $route = $arguments['route']; unset($arguments['route'], $arguments['token']); $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoutePath($route, $arguments)); diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index e853a7ce..bc5bd71f 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -9,6 +9,20 @@ services: T3G\AgencyPack\Blog\Domain\Factory\CommentFormFactory: public: true - T3G\AgencyPack\Blog\Notification\Processor: public: true + T3G\AgencyPack\Blog\Hooks\PageLayoutHeaderHook: + public: true + + T3G\AgencyPack\Blog\Listener\RenderAdditionalContentToRecordList: + tags: + - name: event.listener + identifier: 'tx-blog-render-additional-content-to-record-list' + T3G\AgencyPack\Blog\Listener\RenderAdditionalContentToRecordListV11: + tags: + - name: event.listener + identifier: 'tx-blog-render-additional-content-to-record-list-v11' + T3G\AgencyPack\Blog\Listener\ModifyPageLayoutContent: + tags: + - name: event.listener + identifier: 'tx-blog-modify-page-module-content' diff --git a/Resources/Private/Templates/PageLayout/Header.html b/Resources/Private/Templates/PageLayout/Header.html index 56f8aec9..7f638314 100644 --- a/Resources/Private/Templates/PageLayout/Header.html +++ b/Resources/Private/Templates/PageLayout/Header.html @@ -59,7 +59,7 @@

    -
  • {tag.title}
  • +
  • {tag.title}
@@ -71,7 +71,7 @@

    -
  • {category.title}
  • +
  • {category.title}
diff --git a/ext_localconf.php b/ext_localconf.php index f5ec034d..c1dce835 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -24,11 +24,12 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['blogvh'][] = 'T3G\\AgencyPack\\Blog\\ViewHelpers'; // Register page layout hooks to display additional information for posts. -if (!(bool)$blogConfiguration['disablePageLayoutHeader']) { +if ( + !(bool)$blogConfiguration['disablePageLayoutHeader'] && + (\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class))->getMajorVersion() < 12 +) { $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'][] = \T3G\AgencyPack\Blog\Hooks\PageLayoutHeaderHook::class . '->drawHeader'; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['recordlist/Modules/Recordlist/index.php']['drawHeaderHook'][] - = \T3G\AgencyPack\Blog\Hooks\PageLayoutHeaderHook::class . '->drawHeader'; } // Register new form data provider From 086caafc4d6e6c3eece2392a7d50980590aa4d1f Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Wed, 7 Dec 2022 15:10:03 +0100 Subject: [PATCH 06/13] [TASK] BE Modules --- Classes/Controller/BackendController.php | 61 ++++++++++++------- Classes/Service/SetupService.php | 2 +- Classes/Updates/DatabaseMonthYearUpdate.php | 2 +- Classes/Updates/DatabasePublishDateUpdate.php | 2 +- .../ViewHelpers/Link/Be/AuthorViewHelper.php | 14 ++++- .../Link/Be/CategoryViewHelper.php | 13 +++- .../ViewHelpers/Link/Be/CommentViewHelper.php | 14 ++++- .../ViewHelpers/Link/Be/PostViewHelper.php | 15 ++++- Classes/ViewHelpers/Link/Be/TagViewHelper.php | 14 ++++- Configuration/Backend/Modules.php | 50 +++++++++++++++ .../TCA/tx_blog_domain_model_author.php | 11 +--- .../TCA/tx_blog_domain_model_comment.php | 12 ++-- Resources/Private/Layouts/Backend.html | 5 +- .../Private/Templates/Backend/Comments.html | 6 +- .../Private/Templates/Backend/Posts.html | 10 ++- .../Templates/Backend/SetupWizard.html | 6 +- ext_tables.php | 7 ++- 17 files changed, 181 insertions(+), 63 deletions(-) create mode 100644 Configuration/Backend/Modules.php diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index d321d3d1..874371c6 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -18,7 +18,10 @@ use T3G\AgencyPack\Blog\Service\SetupService; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\ModuleTemplate; +use TYPO3\CMS\Backend\Template\ModuleTemplateFactory; +use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -61,10 +64,16 @@ class BackendController extends ActionController */ protected $blogCacheService; private \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer; - public function __construct(\TYPO3\CMS\Core\Imaging\IconFactory $iconFactory, \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer) - { + protected ModuleTemplateFactory $moduleTemplateFactory; + + public function __construct( + \TYPO3\CMS\Core\Imaging\IconFactory $iconFactory, + \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer, + ModuleTemplateFactory $moduleTemplateFactory + ) { $this->iconFactory = $iconFactory; $this->pageRenderer = $pageRenderer; + $this->moduleTemplateFactory = $moduleTemplateFactory; } /** @@ -101,8 +110,7 @@ public function injectBlogCacheService(CacheService $cacheService): void public function initializeAction(): void { - $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class); - $this->iconFactory = $this->iconFactory; + $this->moduleTemplate = $this->moduleTemplateFactory->create($this->request); $this->buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); $pageRenderer = $this->pageRenderer; @@ -146,9 +154,9 @@ protected function initializeDataTables(): void */ public function setupWizardAction(): ResponseInterface { - return $this->htmlResponse($this->render('Backend/SetupWizard.html', [ + return $this->renderResponse('Backend/SetupWizard.html', [ 'blogSetups' => $this->setupService->determineBlogSetups(), - ])); + ]); } /** @@ -164,16 +172,11 @@ public function postsAction(int $blogSetup = null): ResponseInterface $querySettings = $query->getQuerySettings(); $querySettings->setIgnoreEnableFields(true); $this->postRepository->setDefaultQuerySettings($querySettings); - - $html = $this->render('Backend/Posts.html', [ + return $this->renderResponse('Backend/Posts.html', [ 'blogSetups' => $this->setupService->determineBlogSetups(), 'activeBlogSetup' => $blogSetup, 'posts' => $this->postRepository->findAllByPid($blogSetup), ]); - $response = $this->responseFactory->createResponse() - ->withHeader('Content-Type', 'text/html; charset=utf-8'); - $response->getBody()->write($html ?? $this->view->render()); - return $response; } /** @@ -188,7 +191,7 @@ public function postsAction(int $blogSetup = null): ResponseInterface */ public function commentsAction(string $filter = null, int $blogSetup = null): ResponseInterface { - $html = $this->render('Backend/Comments.html', [ + return $this->renderResponse('Backend/Comments.html', [ 'activeFilter' => $filter, 'activeBlogSetup' => $blogSetup, 'commentCounts' => [ @@ -201,10 +204,6 @@ public function commentsAction(string $filter = null, int $blogSetup = null): Re 'blogSetups' => $this->setupService->determineBlogSetups(), 'comments' => $this->commentRepository->findAllByFilter($filter, $blogSetup), ]); - $response = $this->responseFactory->createResponse() - ->withHeader('Content-Type', 'text/html; charset=utf-8'); - $response->getBody()->write($html ?? $this->view->render()); - return $response; } /** @@ -219,7 +218,7 @@ public function commentsAction(string $filter = null, int $blogSetup = null): Re * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException */ - public function updateCommentStatusAction(string $status, string $filter = null, int $blogSetup = null, array $comments = [], int $comment = null): void + public function updateCommentStatusAction(string $status, string $filter = null, int $blogSetup = null, array $comments = [], int $comment = null): ResponseInterface { if ($comment !== null) { $comments['__identity'][] = $comment; @@ -245,7 +244,8 @@ public function updateCommentStatusAction(string $status, string $filter = null, $this->blogCacheService->flushCacheByTag('tx_blog_comment_' . $comment->getUid()); } } - $this->redirect('comments', null, null, ['filter' => $filter, 'blogSetup' => $blogSetup]); + $uri = $this->uriBuilder->reset()->uriFor('comments', ['filter' => $filter, 'blogSetup' => $blogSetup]); + return new RedirectResponse($uri); } /** @@ -254,14 +254,15 @@ public function updateCommentStatusAction(string $status, string $filter = null, * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException */ - public function createBlogAction(array $data = null): void + public function createBlogAction(array $data = null): ResponseInterface { if ($this->setupService->createBlogSetup($data)) { $this->addFlashMessage('Your blog setup has been created.', 'Congratulation'); } else { $this->addFlashMessage('Sorry, your blog setup could not be created.', 'An error occurred', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR); } - $this->redirect('setupWizard'); + $uri = $this->uriBuilder->reset()->uriFor('setupWizard'); + return new RedirectResponse($uri); } /** @@ -283,7 +284,6 @@ protected function getFluidTemplateObject(string $templateNameAndPath): Standalo $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:blog/Resources/Private/Templates/' . $templateNameAndPath)); $view->setControllerContext($this->getControllerContext()); $view->getRequest()->setControllerExtensionName('Blog'); - return $view; } @@ -301,9 +301,26 @@ protected function render(string $templateNameAndPath, array $values): string $view = $this->getFluidTemplateObject($templateNameAndPath); $view->assign('_template', $templateNameAndPath); $view->assign('action', $this->actionMethodName); + $view->assign('layout', 'Backend'); $view->assignMultiple($values); $this->moduleTemplate->setContent($view->render()); return $this->moduleTemplate->renderContent(); } + + protected function renderResponse(string $templateName, array $values): ResponseInterface + { + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) { + $html = $this->render($templateName, $values); + $response = $this->responseFactory->createResponse() + ->withHeader('Content-Type', 'text/html; charset=utf-8'); + $response->getBody()->write($html ?? $this->view->render()); + return $response; + } + $this->moduleTemplate->assignMultiple(array_merge( + ['_template' => $templateName, 'action' => $this->actionMethodName, 'layout' => 'Module'], + $values + )); + return $this->moduleTemplate->renderResponse($templateName); + } } diff --git a/Classes/Service/SetupService.php b/Classes/Service/SetupService.php index 2f2bd80e..531f16bd 100644 --- a/Classes/Service/SetupService.php +++ b/Classes/Service/SetupService.php @@ -46,7 +46,7 @@ public function determineBlogSetups(): array ->from('pages') ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($blogUid, \PDO::PARAM_INT))) ->execute() - ->fetchColumn(); + ->fetchOne(); $rootline = array_reverse(GeneralUtility::makeInstance(RootlineUtility::class, $blogUid)->get()); $setups[$blogUid] = [ 'uid' => $blogUid, diff --git a/Classes/Updates/DatabaseMonthYearUpdate.php b/Classes/Updates/DatabaseMonthYearUpdate.php index 01d5fa07..a6391777 100644 --- a/Classes/Updates/DatabaseMonthYearUpdate.php +++ b/Classes/Updates/DatabaseMonthYearUpdate.php @@ -130,7 +130,7 @@ public function updateNecessary(): bool ) ) ->execute() - ->fetchColumn(); + ->fetchOne(); return (bool)$elementCount; } diff --git a/Classes/Updates/DatabasePublishDateUpdate.php b/Classes/Updates/DatabasePublishDateUpdate.php index c020afcd..507f0b56 100644 --- a/Classes/Updates/DatabasePublishDateUpdate.php +++ b/Classes/Updates/DatabasePublishDateUpdate.php @@ -127,7 +127,7 @@ public function updateNecessary(): bool ) ) ->execute() - ->fetchColumn(); + ->fetchOne(); return (bool)$elementCount; } diff --git a/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php b/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php index 1fbbb3c7..9a0c8efb 100644 --- a/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php @@ -10,8 +10,10 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link\Be; +use Psr\Http\Message\ServerRequestInterface; use T3G\AgencyPack\Blog\Domain\Model\Author; use TYPO3\CMS\Backend\Routing\UriBuilder; +use TYPO3\CMS\Core\Routing\Route; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; @@ -56,9 +58,11 @@ public function render(): string $routingUriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uri = $routingUriBuilder->buildUriFromRoute('record_edit', ['edit[tx_blog_domain_model_author][' . $authorUid . ']' => 'edit']); $arguments = GeneralUtility::_GET(); - $route = $arguments['route']; + $request = $this->getRequest(); + /** @var Route $route */ + $route = $request->getAttribute('route'); unset($arguments['route'], $arguments['token']); - $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoutePath($route, $arguments)); + $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute($route->getOption('_identifier'), $arguments)); if ($uri !== '') { if ($this->arguments['returnUri']) { return $uri; @@ -73,4 +77,10 @@ public function render(): string return $result; } + + protected function getRequest(): ?ServerRequestInterface + { + return $GLOBALS['TYPO3_REQUEST']; + } + } diff --git a/Classes/ViewHelpers/Link/Be/CategoryViewHelper.php b/Classes/ViewHelpers/Link/Be/CategoryViewHelper.php index 96d61426..c5310022 100644 --- a/Classes/ViewHelpers/Link/Be/CategoryViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/CategoryViewHelper.php @@ -10,8 +10,10 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link\Be; +use Psr\Http\Message\ServerRequestInterface; use T3G\AgencyPack\Blog\Domain\Model\Category; use TYPO3\CMS\Backend\Routing\UriBuilder; +use TYPO3\CMS\Core\Routing\Route; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; @@ -56,9 +58,11 @@ public function render(): string $routingUriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uri = $routingUriBuilder->buildUriFromRoute('record_edit', ['edit[sys_category][' . $categoryUid . ']' => 'edit']); $arguments = GeneralUtility::_GET(); - $route = $arguments['route']; + $request = $this->getRequest(); + /** @var Route $route */ + $route = $request->getAttribute('route'); unset($arguments['route'], $arguments['token']); - $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoutePath($route, $arguments)); + $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute($route->getOption('_identifier'), $arguments)); if ($uri !== '') { if ($this->arguments['returnUri']) { return $uri; @@ -73,4 +77,9 @@ public function render(): string return $result; } + + protected function getRequest(): ?ServerRequestInterface + { + return $GLOBALS['TYPO3_REQUEST']; + } } diff --git a/Classes/ViewHelpers/Link/Be/CommentViewHelper.php b/Classes/ViewHelpers/Link/Be/CommentViewHelper.php index 706e5da6..419d6b8e 100644 --- a/Classes/ViewHelpers/Link/Be/CommentViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/CommentViewHelper.php @@ -10,9 +10,12 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link\Be; +use Psr\Http\Message\ServerRequestInterface; use T3G\AgencyPack\Blog\Domain\Model\Comment; use TYPO3\CMS\Backend\Routing\UriBuilder; +use TYPO3\CMS\Core\Routing\Route; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class CommentViewHelper extends AbstractTagBasedViewHelper @@ -56,9 +59,11 @@ public function render(): string $routingUriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uri = $routingUriBuilder->buildUriFromRoute('record_edit', ['edit[tx_blog_domain_model_comment][' . $commentUid . ']' => 'edit']); $arguments = GeneralUtility::_GET(); - $route = $arguments['route']; + $request = $this->getRequest(); + /** @var Route $route */ + $route = $request->getAttribute('route'); unset($arguments['route'], $arguments['token']); - $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoutePath($route, $arguments)); + $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute($route->getOption('_identifier'), $arguments)); if ($uri !== '') { if ($this->arguments['returnUri']) { return $uri; @@ -73,4 +78,9 @@ public function render(): string return $result; } + + protected function getRequest(): ?ServerRequestInterface + { + return $GLOBALS['TYPO3_REQUEST']; + } } diff --git a/Classes/ViewHelpers/Link/Be/PostViewHelper.php b/Classes/ViewHelpers/Link/Be/PostViewHelper.php index 4a8ebde9..a2abf92d 100644 --- a/Classes/ViewHelpers/Link/Be/PostViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/PostViewHelper.php @@ -10,9 +10,12 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link\Be; +use Psr\Http\Message\ServerRequestInterface; use T3G\AgencyPack\Blog\Domain\Model\Post; use TYPO3\CMS\Backend\Routing\UriBuilder; +use TYPO3\CMS\Core\Routing\Route; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; @@ -57,18 +60,19 @@ public function render(): string switch ($this->arguments['action']) { case 'edit': $uri = (string)$uriBuilder->buildUriFromRoute('record_edit', ['edit[pages][' . $pageUid . ']' => 'edit']); - $route = '/module/web/list'; break; case 'show': default: $uri = (string)$uriBuilder->buildUriFromRoute('web_layout', ['id' => $pageUid]); - $route = '/module/web/layout'; break; } + $request = $this->getRequest(); + /** @var Route $route */ + $route = $request->getAttribute('route'); $arguments = GeneralUtility::_GET(); unset($arguments['route'], $arguments['token']); - $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoutePath($route, $arguments)); + $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute($route->getOption('_identifier'), $arguments)); if ($uri !== '') { if ($this->arguments['returnUri']) { @@ -85,4 +89,9 @@ public function render(): string return $result; } + + protected function getRequest(): ?ServerRequestInterface + { + return $GLOBALS['TYPO3_REQUEST']; + } } diff --git a/Classes/ViewHelpers/Link/Be/TagViewHelper.php b/Classes/ViewHelpers/Link/Be/TagViewHelper.php index dd7e03ba..e37863c0 100644 --- a/Classes/ViewHelpers/Link/Be/TagViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/TagViewHelper.php @@ -10,9 +10,12 @@ namespace T3G\AgencyPack\Blog\ViewHelpers\Link\Be; +use Psr\Http\Message\ServerRequestInterface; use T3G\AgencyPack\Blog\Domain\Model\Tag; use TYPO3\CMS\Backend\Routing\UriBuilder; +use TYPO3\CMS\Core\Routing\Route; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class TagViewHelper extends AbstractTagBasedViewHelper @@ -56,9 +59,11 @@ public function render(): string $routingUriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uri = $routingUriBuilder->buildUriFromRoute('record_edit', ['edit[tx_blog_domain_model_tag][' . $tagUid . ']' => 'edit']); $arguments = GeneralUtility::_GET(); - $route = $arguments['route']; + $request = $this->getRequest(); + /** @var Route $route */ + $route = $request->getAttribute('route'); unset($arguments['route'], $arguments['token']); - $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoutePath($route, $arguments)); + $uri .= '&returnUrl=' . rawurlencode((string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute($route->getOption('_identifier'), $arguments)); if ($uri !== '') { if ($this->arguments['returnUri']) { return $uri; @@ -73,4 +78,9 @@ public function render(): string return $result; } + + protected function getRequest(): ?ServerRequestInterface + { + return $GLOBALS['TYPO3_REQUEST']; + } } diff --git a/Configuration/Backend/Modules.php b/Configuration/Backend/Modules.php new file mode 100644 index 00000000..e1c0b3de --- /dev/null +++ b/Configuration/Backend/Modules.php @@ -0,0 +1,50 @@ + [ + 'position' => ['after' => 'web'], + 'labels' => 'LLL:EXT:blog/Resources/Private/Language/locallang_mod_blog.xlf', + 'iconIdentifier' => 'module-blog', + ], + 'blog_BlogBlogPosts' => [ + 'parent' => 'blog_BlogBlog', + 'access' => 'user', + 'path' => '/module/blog/posts', + 'iconIdentifier' => 'module-blog-posts', + 'labels' => 'LLL:EXT:blog/Resources/Private/Language/locallang_mod_blog_posts.xlf', + 'extensionName' => 'Blog', + 'controllerActions' => [ + \T3G\AgencyPack\Blog\Controller\BackendController::class => [ + 'posts', + ], + ], + ], + 'blog_BlogBlogComments' => [ + 'parent' => 'blog_BlogBlog', + 'access' => 'user', + 'path' => '/module/blog/comments', + 'iconIdentifier' => 'module-blog-comments', + 'labels' => 'LLL:EXT:blog/Resources/Private/Language/locallang_mod_blog_comments.xlf', + 'extensionName' => 'Blog', + 'controllerActions' => [ + \T3G\AgencyPack\Blog\Controller\BackendController::class => [ + 'comments', + 'updateCommentStatus' + ], + ], + ], + 'blog_BlogBlogSetup' => [ + 'parent' => 'blog_BlogBlog', + 'access' => 'admin', + 'path' => '/module/blog/setup', + 'iconIdentifier' => 'module-blog-setup', + 'labels' => 'LLL:EXT:blog/Resources/Private/Language/locallang_mod_blog_setup.xlf', + 'extensionName' => 'Blog', + 'controllerActions' => [ + \T3G\AgencyPack\Blog\Controller\BackendController::class => [ + 'setupWizard', + 'createBlog', + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_blog_domain_model_author.php b/Configuration/TCA/tx_blog_domain_model_author.php index 8e901d71..68a17963 100644 --- a/Configuration/TCA/tx_blog_domain_model_author.php +++ b/Configuration/TCA/tx_blog_domain_model_author.php @@ -254,17 +254,10 @@ ] ], 'sys_language_uid' => [ + 'exclude' => true, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'config' => [ - 'type' => 'select', - 'default' => 0, - 'renderType' => 'selectSingle', - 'foreign_table' => 'sys_language', - 'foreign_table_where' => 'ORDER BY sys_language.title', - 'items' => [ - ['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', -1], - ['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.default_value', 0], - ], + 'type' => 'language', ], ], 'l18n_parent' => [ diff --git a/Configuration/TCA/tx_blog_domain_model_comment.php b/Configuration/TCA/tx_blog_domain_model_comment.php index 9b1a2dbb..2a8d29b4 100644 --- a/Configuration/TCA/tx_blog_domain_model_comment.php +++ b/Configuration/TCA/tx_blog_domain_model_comment.php @@ -31,6 +31,9 @@ 'default' => 'record-blog-comment' ], 'searchFields' => 'uid,comment,name,email', + 'security' => [ + 'ignorePageTypeRestriction' => true, + ], ], 'columns' => [ 'pid' => [ @@ -109,14 +112,7 @@ 'post_language_id' => [ 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'config' => [ - 'type' => 'select', - 'renderType' => 'selectSingle', - 'foreign_table' => 'sys_language', - 'foreign_table_where' => 'ORDER BY sys_language.title', - 'items' => [ - ['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', -1], - ['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.default_value', 0], - ], + 'type' => 'language', ], ], 'status' => [ diff --git a/Resources/Private/Layouts/Backend.html b/Resources/Private/Layouts/Backend.html index 7ef2471d..fce8c9ad 100644 --- a/Resources/Private/Layouts/Backend.html +++ b/Resources/Private/Layouts/Backend.html @@ -1,5 +1,2 @@ - -
- -
+ diff --git a/Resources/Private/Templates/Backend/Comments.html b/Resources/Private/Templates/Backend/Comments.html index 7f1dac77..f1043044 100644 --- a/Resources/Private/Templates/Backend/Comments.html +++ b/Resources/Private/Templates/Backend/Comments.html @@ -1,9 +1,13 @@ - +

+ +
+ +
diff --git a/Resources/Private/Templates/Backend/Posts.html b/Resources/Private/Templates/Backend/Posts.html index 6b9f62ed..02a13acf 100644 --- a/Resources/Private/Templates/Backend/Posts.html +++ b/Resources/Private/Templates/Backend/Posts.html @@ -1,9 +1,13 @@ - +

+ +
+ +
@@ -62,7 +66,7 @@

- + @@ -77,7 +81,7 @@

- + diff --git a/Resources/Private/Templates/Backend/SetupWizard.html b/Resources/Private/Templates/Backend/SetupWizard.html index 69cf93af..a7583003 100644 --- a/Resources/Private/Templates/Backend/SetupWizard.html +++ b/Resources/Private/Templates/Backend/SetupWizard.html @@ -2,12 +2,16 @@ xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers" xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers" > - +

+ +
+ +
diff --git a/ext_tables.php b/ext_tables.php index 1a6d2d38..25fc68fb 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -28,6 +28,9 @@ 'actions-approve' => 'EXT:blog/Resources/Public/Icons/actions-approve.svg', 'actions-decline' => 'EXT:blog/Resources/Public/Icons/actions-decline.svg', 'module-blog' => 'EXT:blog/Resources/Public/Icons/module-blog.svg', + 'module-blog-posts' => 'EXT:blog/Resources/Public/Icons/module-blog-posts.svg', + 'module-blog-comments' => 'EXT:blog/Resources/Public/Icons/module-blog-comments.svg', + 'module-blog-setup' => 'EXT:blog/Resources/Public/Icons/module-blog-setup.svg', 'plugin-blog-archive' => 'EXT:blog/Resources/Public/Icons/plugin-blog-archive.svg', 'plugin-blog-authorposts' => 'EXT:blog/Resources/Public/Icons/plugin-blog-authorposts.svg', 'plugin-blog-authors' => 'EXT:blog/Resources/Public/Icons/plugin-blog-authors.svg', @@ -66,7 +69,8 @@ options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . \T3G\AgencyPack\Blog\Constants::DOKTYPE_BLOG_POST . ') '); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_blog_domain_model_comment'); + if ((\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class))->getMajorVersion() < 12) { + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_blog_domain_model_comment'); // Main Blog \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule( @@ -125,4 +129,5 @@ 'access' => 'admin', ] ); + } }); From df4badeac609af3677cd59c59c4ac24dba7bc839 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Wed, 7 Dec 2022 17:02:53 +0100 Subject: [PATCH 07/13] [TASK] remove deprecated metadata plugin --- Classes/Constants.php | 1 - Classes/Controller/PostController.php | 24 ------------------- Configuration/TCA/Overrides/tt_content.php | 8 ------- Resources/Private/Language/locallang_db.xlf | 6 ----- Resources/Private/Partials/Meta/Default.html | 2 -- .../Private/Templates/Post/Metadata.html | 6 ----- .../Public/Icons/plugin-blog-metadata.svg | 10 -------- ext_localconf.php | 8 ------- ext_tables.php | 1 - 9 files changed, 66 deletions(-) delete mode 100644 Resources/Private/Partials/Meta/Default.html delete mode 100644 Resources/Private/Templates/Post/Metadata.html delete mode 100644 Resources/Public/Icons/plugin-blog-metadata.svg diff --git a/Classes/Constants.php b/Classes/Constants.php index 950e3987..0d3762ff 100644 --- a/Classes/Constants.php +++ b/Classes/Constants.php @@ -58,7 +58,6 @@ class Constants 'blog_comments' => -1600000008, 'blog_header' => -1600000009, 'blog_footer' => -1600000010, - 'blog_metadata' => -1600000011, 'blog_authors' => -1600000012, 'blog_relatedposts' => -1600000013, 'blog_recentpostswidget' => -1600000014, diff --git a/Classes/Controller/PostController.php b/Classes/Controller/PostController.php index e69878aa..e381d51a 100644 --- a/Classes/Controller/PostController.php +++ b/Classes/Controller/PostController.php @@ -380,30 +380,6 @@ public function footerAction(): ResponseInterface return $this->htmlResponse(); } - /** - * Metadata action: output meta information of blog post. - * - * @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException - * @throws \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException - * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException - * - * @deprecated - */ - public function metadataAction(): ResponseInterface - { - trigger_error( - 'Using \T3G\AgencyPack\Blog\Controller\PostController::metadataAction is deprecated. Use headerAction or footerAction instead.', - E_USER_DEPRECATED - ); - - $post = $this->postRepository->findCurrentPost(); - $this->view->assign('post', $post); - if ($post instanceof Post) { - $this->blogCacheService->addTagsForPost($post); - } - return $this->htmlResponse(); - } - /** * Authors action: output author information of blog post. * diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index eb559adc..c16ce498 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -65,14 +65,6 @@ ); $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['blog_sidebar'] = 'recursive,select_key,pages'; -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( - 'Blog', - 'Metadata', - 'LLL:EXT:blog/Resources/Private/Language/locallang_db.xlf:plugin.blog_metadata.title', - 'plugin-blog-metadata' -); -$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['blog_metadata'] = 'recursive,select_key,pages'; - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( 'Blog', 'CommentForm', diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index a4738a4f..578b7c15 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -71,12 +71,6 @@ Displays post footer - - Blog: Metadata (Deprecated, will be removed with v11) - - - Displays post meta data, like date, tags, category... - Blog: Comment Form diff --git a/Resources/Private/Partials/Meta/Default.html b/Resources/Private/Partials/Meta/Default.html deleted file mode 100644 index fed0f23e..00000000 --- a/Resources/Private/Partials/Meta/Default.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/Resources/Private/Templates/Post/Metadata.html b/Resources/Private/Templates/Post/Metadata.html deleted file mode 100644 index abf1287e..00000000 --- a/Resources/Private/Templates/Post/Metadata.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Resources/Public/Icons/plugin-blog-metadata.svg b/Resources/Public/Icons/plugin-blog-metadata.svg deleted file mode 100644 index 6f2250eb..00000000 --- a/Resources/Public/Icons/plugin-blog-metadata.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/ext_localconf.php b/ext_localconf.php index c1dce835..e28663d6 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -145,14 +145,6 @@ function () { ] ); - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'Blog', - 'Metadata', - [ - \T3G\AgencyPack\Blog\Controller\PostController::class => 'metadata', - ] - ); - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( 'Blog', 'Authors', diff --git a/ext_tables.php b/ext_tables.php index 25fc68fb..c5094afc 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -40,7 +40,6 @@ 'plugin-blog-demandedposts' => 'EXT:blog/Resources/Public/Icons/plugin-blog-demandedposts.svg', 'plugin-blog-header' => 'EXT:blog/Resources/Public/Icons/plugin-blog-header.svg', 'plugin-blog-footer' => 'EXT:blog/Resources/Public/Icons/plugin-blog-footer.svg', - 'plugin-blog-metadata' => 'EXT:blog/Resources/Public/Icons/plugin-blog-metadata.svg', 'plugin-blog-posts' => 'EXT:blog/Resources/Public/Icons/plugin-blog-posts.svg', 'plugin-blog-relatedposts' => 'EXT:blog/Resources/Public/Icons/plugin-blog-relatedposts.svg', 'plugin-blog-sidebar' => 'EXT:blog/Resources/Public/Icons/plugin-blog-sidebar.svg', From 35ea4af3396ccbb1f849ac6d075e7e1ed7d84587 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 8 Dec 2022 09:13:54 +0100 Subject: [PATCH 08/13] [TASK] apply cs-fixer --- Classes/Backend/View/BlogPostHeaderContentRenderer.php | 1 - Classes/Controller/BackendController.php | 1 - Classes/Controller/PostController.php | 2 +- Classes/Domain/Finisher/CommentFormFinisher.php | 3 --- Classes/Domain/Model/Post.php | 4 ++-- Classes/Domain/Repository/PostRepository.php | 1 - .../Listener/RenderAdditionalContentToRecordListV11.php | 2 +- Classes/Mail/MailContent.php | 1 - .../Notification/Processor/AdminNotificationProcessor.php | 1 - .../Notification/Processor/AuthorNotificationProcessor.php | 1 - Classes/Updates/AvatarProviderUpdate.php | 2 +- Classes/Updates/DatabaseMonthYearUpdate.php | 2 +- Classes/Updates/DatabasePublishDateUpdate.php | 2 +- Classes/ViewHelpers/Link/Be/AuthorViewHelper.php | 1 - Classes/ViewHelpers/Link/Be/CommentViewHelper.php | 1 - Classes/ViewHelpers/Link/Be/PostViewHelper.php | 1 - Classes/ViewHelpers/Link/Be/TagViewHelper.php | 1 - Configuration/Backend/Modules.php | 7 +++++++ ext_localconf.php | 1 - ext_tables.php | 1 - 20 files changed, 14 insertions(+), 22 deletions(-) diff --git a/Classes/Backend/View/BlogPostHeaderContentRenderer.php b/Classes/Backend/View/BlogPostHeaderContentRenderer.php index e231528b..c64fe700 100644 --- a/Classes/Backend/View/BlogPostHeaderContentRenderer.php +++ b/Classes/Backend/View/BlogPostHeaderContentRenderer.php @@ -43,7 +43,6 @@ public function render(ServerRequestInterface $request): string $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); $pageRenderer->addCssFile('EXT:blog/Resources/Public/Css/pagelayout.min.css', 'stylesheet', 'all', '', false); - $query = $this->postRepository->createQuery(); $querySettings = $query->getQuerySettings(); $querySettings->setIgnoreEnableFields(true); diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index 874371c6..5c765b6d 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -22,7 +22,6 @@ use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Fluid\View\StandaloneView; diff --git a/Classes/Controller/PostController.php b/Classes/Controller/PostController.php index e381d51a..f9fab427 100644 --- a/Classes/Controller/PostController.php +++ b/Classes/Controller/PostController.php @@ -27,11 +27,11 @@ use TYPO3\CMS\Core\Http\NormalizedParams; use TYPO3\CMS\Core\Site\Entity\SiteLanguage; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -use TYPO3Fluid\Fluid\View\ViewInterface; use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; +use TYPO3Fluid\Fluid\View\ViewInterface; class PostController extends ActionController { diff --git a/Classes/Domain/Finisher/CommentFormFinisher.php b/Classes/Domain/Finisher/CommentFormFinisher.php index c11d89d1..82017266 100644 --- a/Classes/Domain/Finisher/CommentFormFinisher.php +++ b/Classes/Domain/Finisher/CommentFormFinisher.php @@ -20,7 +20,6 @@ use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Service\ExtensionService; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher; @@ -33,7 +32,6 @@ */ class CommentFormFinisher extends AbstractFinisher { - protected FlashMessageService $flashMessageService; protected PostRepository $postRepository; protected CacheService $cacheService; @@ -41,7 +39,6 @@ class CommentFormFinisher extends AbstractFinisher protected TypoScriptService $typoScriptService; protected ExtensionService $extensionService; - public function injectFlashMessageService(FlashMessageService $flashMessageService): void { $this->flashMessageService = $flashMessageService; diff --git a/Classes/Domain/Model/Post.php b/Classes/Domain/Model/Post.php index 07a1e22f..bcb2f339 100644 --- a/Classes/Domain/Model/Post.php +++ b/Classes/Domain/Model/Post.php @@ -374,7 +374,7 @@ public function getComments(): ObjectStorage */ public function getActiveComments() { - return (GeneralUtility::makeInstance(CommentRepository::class))->findAllByPost($this); + return GeneralUtility::makeInstance(CommentRepository::class)->findAllByPost($this); } /** @@ -539,7 +539,7 @@ public function getCrdateYear(): int */ public function getUri(): string { - return (GeneralUtility::makeInstance(UriBuilder::class)) + return GeneralUtility::makeInstance(UriBuilder::class) ->setCreateAbsoluteUri(true) ->setTargetPageUid($this->getUid()) ->build(); diff --git a/Classes/Domain/Repository/PostRepository.php b/Classes/Domain/Repository/PostRepository.php index 0df972d3..58c3cc4d 100644 --- a/Classes/Domain/Repository/PostRepository.php +++ b/Classes/Domain/Repository/PostRepository.php @@ -23,7 +23,6 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\RootlineUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; diff --git a/Classes/Listener/RenderAdditionalContentToRecordListV11.php b/Classes/Listener/RenderAdditionalContentToRecordListV11.php index 70eec319..06ee9b9f 100644 --- a/Classes/Listener/RenderAdditionalContentToRecordListV11.php +++ b/Classes/Listener/RenderAdditionalContentToRecordListV11.php @@ -12,9 +12,9 @@ namespace T3G\AgencyPack\Blog\Listener; use T3G\AgencyPack\Blog\Backend\View\BlogPostHeaderContentRenderer; -use TYPO3\CMS\Recordlist\Event\RenderAdditionalContentToRecordListEvent; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Recordlist\Event\RenderAdditionalContentToRecordListEvent; class RenderAdditionalContentToRecordListV11 { diff --git a/Classes/Mail/MailContent.php b/Classes/Mail/MailContent.php index 9b588160..2e4de96a 100644 --- a/Classes/Mail/MailContent.php +++ b/Classes/Mail/MailContent.php @@ -17,7 +17,6 @@ class MailContent { - /** * @param string $template * @param array $arguments diff --git a/Classes/Notification/Processor/AdminNotificationProcessor.php b/Classes/Notification/Processor/AdminNotificationProcessor.php index d11fa1cf..053da13b 100644 --- a/Classes/Notification/Processor/AdminNotificationProcessor.php +++ b/Classes/Notification/Processor/AdminNotificationProcessor.php @@ -19,7 +19,6 @@ class AdminNotificationProcessor implements ProcessorInterface { - /** * Process the notification * diff --git a/Classes/Notification/Processor/AuthorNotificationProcessor.php b/Classes/Notification/Processor/AuthorNotificationProcessor.php index f69df131..c5c88974 100644 --- a/Classes/Notification/Processor/AuthorNotificationProcessor.php +++ b/Classes/Notification/Processor/AuthorNotificationProcessor.php @@ -21,7 +21,6 @@ class AuthorNotificationProcessor implements ProcessorInterface { - /** * Process the notification * diff --git a/Classes/Updates/AvatarProviderUpdate.php b/Classes/Updates/AvatarProviderUpdate.php index 28124b0e..67231b5f 100644 --- a/Classes/Updates/AvatarProviderUpdate.php +++ b/Classes/Updates/AvatarProviderUpdate.php @@ -15,7 +15,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Utility\GeneralUtility; use /** @noinspection PhpInternalEntityUsedInspection */ - TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; +TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; class AvatarProviderUpdate implements UpgradeWizardInterface diff --git a/Classes/Updates/DatabaseMonthYearUpdate.php b/Classes/Updates/DatabaseMonthYearUpdate.php index a6391777..00f44a43 100644 --- a/Classes/Updates/DatabaseMonthYearUpdate.php +++ b/Classes/Updates/DatabaseMonthYearUpdate.php @@ -14,7 +14,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; use /** @noinspection PhpInternalEntityUsedInspection */ - TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; +TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** diff --git a/Classes/Updates/DatabasePublishDateUpdate.php b/Classes/Updates/DatabasePublishDateUpdate.php index 507f0b56..41f30d60 100644 --- a/Classes/Updates/DatabasePublishDateUpdate.php +++ b/Classes/Updates/DatabasePublishDateUpdate.php @@ -14,7 +14,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; use /** @noinspection PhpInternalEntityUsedInspection */ - TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; +TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** diff --git a/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php b/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php index 9a0c8efb..596740dc 100644 --- a/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php @@ -82,5 +82,4 @@ protected function getRequest(): ?ServerRequestInterface { return $GLOBALS['TYPO3_REQUEST']; } - } diff --git a/Classes/ViewHelpers/Link/Be/CommentViewHelper.php b/Classes/ViewHelpers/Link/Be/CommentViewHelper.php index 419d6b8e..6f6a4629 100644 --- a/Classes/ViewHelpers/Link/Be/CommentViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/CommentViewHelper.php @@ -15,7 +15,6 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Routing\Route; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class CommentViewHelper extends AbstractTagBasedViewHelper diff --git a/Classes/ViewHelpers/Link/Be/PostViewHelper.php b/Classes/ViewHelpers/Link/Be/PostViewHelper.php index a2abf92d..40711cbd 100644 --- a/Classes/ViewHelpers/Link/Be/PostViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/PostViewHelper.php @@ -15,7 +15,6 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Routing\Route; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; diff --git a/Classes/ViewHelpers/Link/Be/TagViewHelper.php b/Classes/ViewHelpers/Link/Be/TagViewHelper.php index e37863c0..85cd8294 100644 --- a/Classes/ViewHelpers/Link/Be/TagViewHelper.php +++ b/Classes/ViewHelpers/Link/Be/TagViewHelper.php @@ -15,7 +15,6 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Routing\Route; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class TagViewHelper extends AbstractTagBasedViewHelper diff --git a/Configuration/Backend/Modules.php b/Configuration/Backend/Modules.php index e1c0b3de..f5fb4813 100644 --- a/Configuration/Backend/Modules.php +++ b/Configuration/Backend/Modules.php @@ -1,5 +1,12 @@ [ 'position' => ['after' => 'web'], diff --git a/ext_localconf.php b/ext_localconf.php index e28663d6..fbec7caa 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -220,7 +220,6 @@ function () { ); } - /** @noinspection UnsupportedStringOffsetOperationsInspection */ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['Blog'] = \T3G\AgencyPack\Blog\Hooks\DataHandlerHook::class; diff --git a/ext_tables.php b/ext_tables.php index c5094afc..031aa404 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -12,7 +12,6 @@ } call_user_func(function () { - // Add new page type: $GLOBALS['PAGES_TYPES'][\T3G\AgencyPack\Blog\Constants::DOKTYPE_BLOG_POST] = [ 'type' => 'web', From c6412c4eeeab6bfc29e84c09e681d310852d2ed8 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 8 Dec 2022 10:29:41 +0100 Subject: [PATCH 09/13] [TASK] replace signal slot with event --- .../AfterPackageActivation.php} | 33 +++++++------------ Configuration/Services.yaml | 10 ++++-- ext_localconf.php | 10 ------ 3 files changed, 18 insertions(+), 35 deletions(-) rename Classes/{Hooks/ExtensionUpdate.php => Listener/AfterPackageActivation.php} (72%) diff --git a/Classes/Hooks/ExtensionUpdate.php b/Classes/Listener/AfterPackageActivation.php similarity index 72% rename from Classes/Hooks/ExtensionUpdate.php rename to Classes/Listener/AfterPackageActivation.php index d5a38e64..d9a538dd 100644 --- a/Classes/Hooks/ExtensionUpdate.php +++ b/Classes/Listener/AfterPackageActivation.php @@ -1,4 +1,5 @@ getPackageKey(); if ($extensionKey !== 'blog') { return; } $registry = GeneralUtility::makeInstance(Registry::class); - $appliedUpdates = $registry->get(__CLASS__, 'updates', []); + $appliedUpdates = $registry->get(self::LEGACY_CLASSNAME, 'updates', []); foreach ($this->updates as $update) { if (!isset($appliedUpdates[$update])) { $result = $this->$update(); @@ -47,12 +39,9 @@ public function afterExtensionInstall($extensionKey, InstallUtility $installUtil } } } - $registry->set(__CLASS__, 'updates', $appliedUpdates); + $registry->set(self::LEGACY_CLASSNAME, 'updates', $appliedUpdates); } - /** - * @return bool - */ protected function migrateCommentsStatus(): bool { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index bc5bd71f..2eecc1da 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -17,12 +17,16 @@ services: T3G\AgencyPack\Blog\Listener\RenderAdditionalContentToRecordList: tags: - name: event.listener - identifier: 'tx-blog-render-additional-content-to-record-list' + identifier: 't3g/blog/render-additional-content-to-record-list' T3G\AgencyPack\Blog\Listener\RenderAdditionalContentToRecordListV11: tags: - name: event.listener - identifier: 'tx-blog-render-additional-content-to-record-list-v11' + identifier: 't3g/blog/render-additional-content-to-record-list-v11' T3G\AgencyPack\Blog\Listener\ModifyPageLayoutContent: tags: - name: event.listener - identifier: 'tx-blog-modify-page-module-content' + identifier: 't3g/blog/modify-page-module-content' + T3G\AgencyPack\Blog\Listener\AfterPackageActivation: + tags: + - name: event.listener + identifier: 't3g/blog/after-package-activation' diff --git a/ext_localconf.php b/ext_localconf.php index fbec7caa..f2a403b5 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -210,16 +210,6 @@ function () { ] ); - if ((\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class))->getMajorVersion() < 12) { - $dispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); - $dispatcher->connect( - \TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class, - 'afterExtensionInstall', - \T3G\AgencyPack\Blog\Hooks\ExtensionUpdate::class, - 'afterExtensionInstall' - ); - } - /** @noinspection UnsupportedStringOffsetOperationsInspection */ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['Blog'] = \T3G\AgencyPack\Blog\Hooks\DataHandlerHook::class; From 86facf61fcc155348c4c953cc8463b50d760dd6b Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 8 Dec 2022 10:32:09 +0100 Subject: [PATCH 10/13] [TASK] allow composer plugins --- composer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f7451805..633cd892 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,11 @@ "bin-dir": ".build/bin", "discard-changes": true, "optimize-autoloader": true, - "vendor-dir": ".build/vendor" + "vendor-dir": ".build/vendor", + "allow-plugins": { + "typo3/cms-composer-installers": true, + "typo3/class-alias-loader": true + } }, "extra": { "typo3/cms": { From 50274a140d05d4b356207808f12beb79ce3a6750 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 8 Dec 2022 10:36:02 +0100 Subject: [PATCH 11/13] [TASK] add phpspec/prophecy as dependency --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 633cd892..ff03afa0 100644 --- a/composer.json +++ b/composer.json @@ -114,6 +114,7 @@ "typo3/testing-framework": "^6.4", "bk2k/bootstrap-package": "^12", "bk2k/extension-helper": "^1.0", - "overtrue/phplint": "^2.4" + "overtrue/phplint": "^2.4", + "phpspec/prophecy": "^1.16" } } From c1af152c9dfe21454953b82c5ce5d02d5e484123 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Fri, 23 Dec 2022 14:06:16 +0100 Subject: [PATCH 12/13] [BUGFIX] parse settings --- Classes/Domain/Repository/PostRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Domain/Repository/PostRepository.php b/Classes/Domain/Repository/PostRepository.php index 58c3cc4d..d7907f04 100644 --- a/Classes/Domain/Repository/PostRepository.php +++ b/Classes/Domain/Repository/PostRepository.php @@ -483,7 +483,7 @@ protected function getStoragePidsFromTypoScript(): array { $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); - return GeneralUtility::intExplode(',', $settings['persistence']['storagePid']); + return GeneralUtility::intExplode(',', (string)($settings['persistence']['storagePid'] ?? '')); } /** From eec8a71d611679d90449ddf07add176800830452 Mon Sep 17 00:00:00 2001 From: Benni Mack Date: Thu, 11 May 2023 23:16:01 +0200 Subject: [PATCH 13/13] [TASK] Add v12 ViewHelper compat --- Classes/ViewHelpers/Link/AuthorViewHelper.php | 1 + Classes/ViewHelpers/Link/TagViewHelper.php | 1 + 2 files changed, 2 insertions(+) diff --git a/Classes/ViewHelpers/Link/AuthorViewHelper.php b/Classes/ViewHelpers/Link/AuthorViewHelper.php index 7792e8cd..4700e835 100644 --- a/Classes/ViewHelpers/Link/AuthorViewHelper.php +++ b/Classes/ViewHelpers/Link/AuthorViewHelper.php @@ -94,6 +94,7 @@ protected function getUriBuilder(int $pageUid, array $additionalParams, bool $rs $uriBuilder->reset() ->setTargetPageUid($pageUid) ->setArguments($additionalParams); + $uriBuilder->setRequest($this->renderingContext->getRequest()); if ($rssFormat) { $uriBuilder ->setTargetPageType((int)$this->getTypoScriptFrontendController()->tmpl->setup['blog_rss_author.']['typeNum']); diff --git a/Classes/ViewHelpers/Link/TagViewHelper.php b/Classes/ViewHelpers/Link/TagViewHelper.php index 3950f023..7aa8afe9 100644 --- a/Classes/ViewHelpers/Link/TagViewHelper.php +++ b/Classes/ViewHelpers/Link/TagViewHelper.php @@ -55,6 +55,7 @@ public function render(): string $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->reset() ->setTargetPageUid($pageUid); + $uriBuilder->setRequest($this->renderingContext->getRequest()); if ($rssFormat) { $uriBuilder ->setTargetPageType((int)$this->getTypoScriptFrontendController()->tmpl->setup['blog_rss_tag.']['typeNum']);