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/Backend/View/BlogPostHeaderContentRenderer.php b/Classes/Backend/View/BlogPostHeaderContentRenderer.php
new file mode 100644
index 00000000..c64fe700
--- /dev/null
+++ b/Classes/Backend/View/BlogPostHeaderContentRenderer.php
@@ -0,0 +1,64 @@
+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/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/BackendController.php b/Classes/Controller/BackendController.php
index 7f000494..5c765b6d 100644
--- a/Classes/Controller/BackendController.php
+++ b/Classes/Controller/BackendController.php
@@ -18,8 +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\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Fluid\View\StandaloneView;
@@ -60,6 +62,18 @@ class BackendController extends ActionController
* @var CacheService
*/
protected $blogCacheService;
+ private \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;
+ }
/**
* @param SetupService $setupService
@@ -95,11 +109,10 @@ public function injectBlogCacheService(CacheService $cacheService): void
public function initializeAction(): void
{
- $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
- $this->iconFactory = $this->moduleTemplate->getIconFactory();
+ $this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);
$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 +120,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 +131,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);
}
@@ -140,9 +153,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(),
- ]));
+ ]);
}
/**
@@ -158,16 +171,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;
}
/**
@@ -182,7 +190,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' => [
@@ -195,10 +203,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;
}
/**
@@ -213,7 +217,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;
@@ -239,7 +243,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);
}
/**
@@ -248,14 +253,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', FlashMessage::ERROR);
+ $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);
}
/**
@@ -277,7 +283,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;
}
@@ -295,9 +300,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/Controller/PostController.php b/Classes/Controller/PostController.php
index c5b96a6e..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 TYPO3\CMS\Extbase\Mvc\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
{
@@ -111,11 +111,10 @@ 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
{
- parent::initializeView($view);
if ($this->request->getFormat() === 'rss') {
$action = '.' . $this->request->getControllerActionName();
$arguments = [];
@@ -381,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/Classes/Domain/Factory/CommentFormFactory.php b/Classes/Domain/Factory/CommentFormFactory.php
index 52b80a5b..b8bfa7d0 100644
--- a/Classes/Domain/Factory/CommentFormFactory.php
+++ b/Classes/Domain/Factory/CommentFormFactory.php
@@ -12,10 +12,10 @@
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;
-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 +29,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 +47,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 +57,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 +80,29 @@ 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));
+ 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');
$explanationText->setProperty('text', LocalizationUtility::translate('label.required.field', 'blog') . ' ' . LocalizationUtility::translate('label.required.field.explanation', 'blog'));
@@ -95,17 +110,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 179d0a52..82017266 100644
--- a/Classes/Domain/Finisher/CommentFormFinisher.php
+++ b/Classes/Domain/Finisher/CommentFormFinisher.php
@@ -17,10 +17,13 @@
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,32 +32,70 @@
*/
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',
'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,
],
];
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 +104,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..bcb2f339 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..97a4312f 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,13 @@
class CategoryRepository extends Repository
{
+ protected ConfigurationManagerInterface $configurationManager;
+
+ public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void
+ {
+ $this->configurationManager = $configurationManager;
+ }
+
/**
* Initializes the repository.
*
@@ -28,9 +36,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 +81,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 +93,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..4be41a22 100644
--- a/Classes/Domain/Repository/CommentRepository.php
+++ b/Classes/Domain/Repository/CommentRepository.php
@@ -23,25 +23,26 @@
class CommentRepository extends Repository
{
- /**
- * @var ConfigurationManagerInterface
- */
- protected $configurationManager;
+ protected ConfigurationManagerInterface $configurationManager;
+ protected array $settings = [];
- /**
- * @var array
- */
- protected $settings;
+ public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void
+ {
+ $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 +64,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 +76,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 +104,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 +133,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 +150,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 +182,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..d7907f04 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;
@@ -34,17 +33,24 @@
class PostRepository extends Repository
{
- /**
- * @var array
- */
- protected $defaultConstraints = [];
+ protected array $defaultConstraints = [];
+ protected ConfigurationManagerInterface $configurationManager;
+
+ public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void
+ {
+ $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 +58,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 +106,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 +159,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 +196,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 +222,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 +241,7 @@ public function findAllByCategory(Category $category)
$constraints[] = $storagePidConstraint;
}
- return $query->matching($query->logicalAnd($constraints))->execute();
+ return $query->matching($query->logicalAnd(...$constraints))->execute();
}
/**
@@ -254,7 +260,7 @@ public function findAllByTag(Tag $tag)
$constraints[] = $storagePidConstraint;
}
- return $query->matching($query->logicalAnd($constraints))->execute();
+ return $query->matching($query->logicalAnd(...$constraints))->execute();
}
/**
@@ -284,7 +290,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 +330,7 @@ protected function getPostWithLanguage(int $pageId, int $languageId): ?Post
}
return $query
- ->matching($query->logicalAnd($constraints))
+ ->matching($query->logicalAnd(...$constraints))
->execute()
->getFirst();
}
@@ -377,7 +383,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,10 +481,9 @@ 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']);
+ return GeneralUtility::intExplode(',', (string)($settings['persistence']['storagePid'] ?? ''));
}
/**
diff --git a/Classes/Domain/Repository/TagRepository.php b/Classes/Domain/Repository/TagRepository.php
index 963e4129..433e32fd 100644
--- a/Classes/Domain/Repository/TagRepository.php
+++ b/Classes/Domain/Repository/TagRepository.php
@@ -18,12 +18,13 @@
class TagRepository extends Repository
{
- /**
- * Plugin settings
- *
- * @var array $pluginSettings
- */
- protected $pluginSettings;
+ protected array $pluginSettings = [];
+ protected ConfigurationManagerInterface $configurationManager;
+
+ public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void
+ {
+ $this->configurationManager = $configurationManager;
+ }
/**
* Initializes the repository.
@@ -36,9 +37,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 +80,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/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/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/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..06ee9b9f
--- /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/Mail/MailContent.php b/Classes/Mail/MailContent.php
index a9238926..2e4de96a 100644
--- a/Classes/Mail/MailContent.php
+++ b/Classes/Mail/MailContent.php
@@ -10,14 +10,13 @@
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
{
-
/**
* @param string $template
* @param array $arguments
@@ -48,17 +47,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..053da13b 100644
--- a/Classes/Notification/Processor/AdminNotificationProcessor.php
+++ b/Classes/Notification/Processor/AdminNotificationProcessor.php
@@ -13,9 +13,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 AdminNotificationProcessor implements ProcessorInterface
{
@@ -41,9 +41,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 +60,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..c5c88974 100644
--- a/Classes/Notification/Processor/AuthorNotificationProcessor.php
+++ b/Classes/Notification/Processor/AuthorNotificationProcessor.php
@@ -15,13 +15,12 @@
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
{
-
/**
* Process the notification
*
@@ -45,9 +44,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 +67,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..531f16bd 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)) {
@@ -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,
@@ -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 2c7a9030..0d0f78a9 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;
}
@@ -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 d4856ba4..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
@@ -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(
@@ -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..37d18b1d 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;
}
@@ -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 22a41be1..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'];
}
@@ -91,7 +91,7 @@ public function updateNecessary(): bool
)
)
->execute()
- ->fetchColumn(0);
+ ->fetchOne();
return (bool)$elementCount;
}
@@ -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..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;
/**
@@ -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')
@@ -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 aaa5dc84..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;
/**
@@ -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')
@@ -127,7 +127,7 @@ public function updateNecessary(): bool
)
)
->execute()
- ->fetchColumn();
+ ->fetchOne();
return (bool)$elementCount;
}
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 1128e25e..6e828cfa 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;
}
@@ -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/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..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
@@ -24,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
{
@@ -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 9b9af4a9..4700e835 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;
@@ -26,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
{
@@ -89,10 +90,11 @@ 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);
+ $uriBuilder->setRequest($this->renderingContext->getRequest());
if ($rssFormat) {
$uriBuilder
->setTargetPageType((int)$this->getTypoScriptFrontendController()->tmpl->setup['blog_rss_author.']['typeNum']);
diff --git a/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php b/Classes/ViewHelpers/Link/Be/AuthorViewHelper.php
index ecb46082..596740dc 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;
@@ -27,7 +29,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
{
@@ -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,9 @@ 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 f7f8a5d7..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;
@@ -27,7 +29,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
{
@@ -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 33f6a57c..6f6a4629 100644
--- a/Classes/ViewHelpers/Link/Be/CommentViewHelper.php
+++ b/Classes/ViewHelpers/Link/Be/CommentViewHelper.php
@@ -10,8 +10,10 @@
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 TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
@@ -27,7 +29,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
{
@@ -56,9 +58,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 +77,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 9cab8079..40711cbd 100644
--- a/Classes/ViewHelpers/Link/Be/PostViewHelper.php
+++ b/Classes/ViewHelpers/Link/Be/PostViewHelper.php
@@ -10,8 +10,10 @@
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\LocalizationUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
@@ -28,7 +30,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
{
@@ -64,10 +66,12 @@ public function render(): string
break;
}
+ $request = $this->getRequest();
+ /** @var Route $route */
+ $route = $request->getAttribute('route');
$arguments = GeneralUtility::_GET();
- $route = $arguments['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']) {
@@ -84,4 +88,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 15344870..85cd8294 100644
--- a/Classes/ViewHelpers/Link/Be/TagViewHelper.php
+++ b/Classes/ViewHelpers/Link/Be/TagViewHelper.php
@@ -10,8 +10,10 @@
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 TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
@@ -27,7 +29,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
{
@@ -56,9 +58,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 +77,9 @@ public function render(): string
return $result;
}
+
+ protected function getRequest(): ?ServerRequestInterface
+ {
+ return $GLOBALS['TYPO3_REQUEST'];
+ }
}
diff --git a/Classes/ViewHelpers/Link/CategoryViewHelper.php b/Classes/ViewHelpers/Link/CategoryViewHelper.php
index 4606efb0..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
@@ -25,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
{
@@ -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 f2b0fb2e..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
@@ -25,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
{
@@ -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 62de24c9..7aa8afe9 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
@@ -25,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
{
@@ -50,9 +52,10 @@ public function render(): string
$arguments = [
'tag' => $tag->getUid(),
];
- $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
+ $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']);
diff --git a/Configuration/Backend/Modules.php b/Configuration/Backend/Modules.php
new file mode 100644
index 00000000..f5fb4813
--- /dev/null
+++ b/Configuration/Backend/Modules.php
@@ -0,0 +1,57 @@
+ [
+ '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/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..2eecc1da 100644
--- a/Configuration/Services.yaml
+++ b/Configuration/Services.yaml
@@ -6,3 +6,27 @@ services:
T3G\AgencyPack\Blog\:
resource: '../Classes/*'
+
+ 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: 't3g/blog/render-additional-content-to-record-list'
+ T3G\AgencyPack\Blog\Listener\RenderAdditionalContentToRecordListV11:
+ tags:
+ - name: event.listener
+ identifier: 't3g/blog/render-additional-content-to-record-list-v11'
+ T3G\AgencyPack\Blog\Listener\ModifyPageLayoutContent:
+ tags:
+ - name: event.listener
+ 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/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/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/Configuration/TCA/tx_blog_domain_model_author.php b/Configuration/TCA/tx_blog_domain_model_author.php
index 7910ecbe..68a17963 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,
@@ -255,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 9c855a10..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' => [
@@ -63,7 +66,6 @@
'label' => $ll . 'tx_blog_domain_model_comment.author',
'config' => [
'type' => 'group',
- 'internal_type' => 'db',
'allowed' => 'fe_users',
'size' => 1,
'maxitems' => 1,
@@ -110,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/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 @@