Skip to content

[WIP] v14 with site sets #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -15,14 +15,9 @@ jobs:
strategy:
fail-fast: false
matrix:
typo3: ['^12', '^13']
php: ['8.1', '8.2', '8.3']
mysql: ['5.7', '8.0', '8.4']
exclude:
- typo3: '^13'
mysql: '5.7'
- typo3: '^13'
php: '8.1'
typo3: ['^13']
php: ['8.2', '8.3']
mysql: ['8.0', '8.4']
steps:
- id: checkout
name: Checkout Code
2 changes: 1 addition & 1 deletion Classes/Controller/CommentController.php
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ public function commentsAction(): ResponseInterface
if ($post instanceof Post) {
$comments = $this->commentService->getCommentsByPost($post);
foreach ($comments as $comment) {
$this->cacheService->addTagToPage('tx_blog_comment_' . $comment->getUid());
$this->cacheService->addTagToPage($this->request, 'tx_blog_comment_' . $comment->getUid());
}
$this->view->assign('comments', $comments);
$this->view->assign('post', $post);
8 changes: 4 additions & 4 deletions Classes/Controller/PostController.php
Original file line number Diff line number Diff line change
@@ -256,7 +256,7 @@ public function listPostsByTagAction(?Tag $tag = null, int $currentPage = 1): Re
*/
public function sidebarAction(): ResponseInterface
{
return $this->htmlResponse();
return $this->htmlResponse('');
}

/**
@@ -267,7 +267,7 @@ public function headerAction(): ResponseInterface
$post = $this->postRepository->findCurrentPost();
$this->view->assign('post', $post);
if ($post instanceof Post) {
$this->blogCacheService->addTagsForPost($post);
$this->blogCacheService->addTagsForPost($this->request, $post);
}
return $this->htmlResponse();
}
@@ -280,7 +280,7 @@ public function footerAction(): ResponseInterface
$post = $this->postRepository->findCurrentPost();
$this->view->assign('post', $post);
if ($post instanceof Post) {
$this->blogCacheService->addTagsForPost($post);
$this->blogCacheService->addTagsForPost($this->request, $post);
}
return $this->htmlResponse();
}
@@ -293,7 +293,7 @@ public function authorsAction(): ResponseInterface
$post = $this->postRepository->findCurrentPost();
$this->view->assign('post', $post);
if ($post instanceof Post) {
$this->blogCacheService->addTagsForPost($post);
$this->blogCacheService->addTagsForPost($this->request, $post);
}
return $this->htmlResponse();
}
8 changes: 4 additions & 4 deletions Classes/Controller/WidgetController.php
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ public function categoriesAction(): ResponseInterface
$this->view->assign('categories', $categories);
$this->view->assign('currentCategory', $currentCategory);
foreach ($categories as $category) {
$this->cacheService->addTagToPage('tx_blog_category_' . $category->getUid());
$this->cacheService->addTagToPage($this->request, 'tx_blog_category_' . $category->getUid());
}
return $this->htmlResponse();
}
@@ -92,7 +92,7 @@ public function tagsAction(): ResponseInterface
}
unset($tagReference);
foreach ($tags as $tag) {
$this->cacheService->addTagToPage('tx_blog_tag_' . (int)$tag['uid']);
$this->cacheService->addTagToPage($this->request, 'tx_blog_tag_' . (int)$tag['uid']);
}
$this->view->assign('tags', $tags);
$this->view->assign('currentTag', $currentTag);
@@ -108,7 +108,7 @@ public function recentPostsAction(): ResponseInterface
: $this->postRepository->findAll();

foreach ($posts as $post) {
$this->cacheService->addTagsForPost($post);
$this->cacheService->addTagsForPost($this->request, $post);
}
$this->view->assign('posts', $posts);
return $this->htmlResponse();
@@ -121,7 +121,7 @@ public function commentsAction(): ResponseInterface
$comments = $this->commentRepository->findActiveComments($limit, $blogSetup);
$this->view->assign('comments', $comments);
foreach ($comments as $comment) {
$this->cacheService->addTagToPage('tx_blog_comment_' . $comment->getUid());
$this->cacheService->addTagToPage($this->request, 'tx_blog_comment_' . $comment->getUid());
}
return $this->htmlResponse();
}
9 changes: 2 additions & 7 deletions Classes/Domain/Factory/CommentFormFactory.php
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
use Psr\Http\Message\ServerRequestInterface;
use T3G\AgencyPack\Blog\Domain\Finisher\CommentFormFinisher;
use T3G\AgencyPack\Blog\Domain\Validator\GoogleCaptchaValidator;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
@@ -88,12 +87,8 @@ public function build(array $configuration, ?string $prototypeName = null, ?Serv
$commentField = $page->createElement('comment', 'Textarea');
$commentField->setLabel((string) LocalizationUtility::translate('form.comment.comment', 'blog'));
$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]);
}
$stringLengthValidator = GeneralUtility::makeInstance(StringLengthValidator::class);
$stringLengthValidator->setOptions(['minimum' => 5]);
$commentField->addValidator($stringLengthValidator);

$explanationText = $page->createElement('explanation', 'StaticText');
29 changes: 14 additions & 15 deletions Classes/Service/CacheService.php
Original file line number Diff line number Diff line change
@@ -10,8 +10,10 @@

namespace T3G\AgencyPack\Blog\Service;

use Psr\Http\Message\ServerRequestInterface;
use T3G\AgencyPack\Blog\Domain\Model\Post;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\CacheTag;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

@@ -20,31 +22,33 @@
*/
class CacheService
{
public function addTagsForPost(Post $post): void
public function addTagsForPost(ServerRequestInterface $request, Post $post): void
{
$this->addTagToPage('tx_blog_post_' . $post->getUid());
$this->addTagToPage($request, 'tx_blog_post_' . $post->getUid());
foreach ($post->getAuthors() as $author) {
$this->addTagToPage('tx_blog_author_' . $author->getUid());
$this->addTagToPage($request, 'tx_blog_author_' . $author->getUid());
}
foreach ($post->getCategories() as $category) {
$this->addTagToPage('tx_blog_category_' . $category->getUid());
$this->addTagToPage($request, 'tx_blog_category_' . $category->getUid());
}
foreach ($post->getTags() as $tag) {
$this->addTagToPage('tx_blog_tag_' . $tag->getUid());
$this->addTagToPage($request, 'tx_blog_tag_' . $tag->getUid());
}
foreach ($post->getActiveComments() as $comment) {
$this->addTagToPage('tx_blog_comment_' . $comment->getUid());
$this->addTagToPage($request, 'tx_blog_comment_' . $comment->getUid());
}
}

public function addTagToPage(string $tag): void
public function addTagToPage(ServerRequestInterface $request, string $tag): void
{
$this->addTagsToPage([$tag]);
$this->addTagsToPage($request, [$tag]);
}

public function addTagsToPage(array $tags): void
public function addTagsToPage(ServerRequestInterface $request, array $tags): void
{
$this->getTypoScriptFrontendController()->addCacheTags($tags);
$request->getAttribute('frontend.cache.collector')->addCacheTags(
...array_map(fn(string $tag) => new CacheTag($tag), $tags)
);
}

public function flushCacheByTag(string $tag): void
@@ -58,9 +62,4 @@ public function flushCacheByTags(array $tags): void
->getCache('pages')
->flushByTags($tags);
}

protected function getTypoScriptFrontendController(): TypoScriptFrontendController
{
return $GLOBALS['TSFE'];
}
}
49 changes: 49 additions & 0 deletions Classes/Updates/ListTypeMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
declare(strict_types = 1);

/*
* This file is part of the package t3g/blog.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

namespace T3G\AgencyPack\Blog\Updates;

use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\AbstractListTypeToCTypeUpdate;

#[UpgradeWizard(ListTypeMigration::class)]
final class ListTypeMigration extends AbstractListTypeToCTypeUpdate
{
protected function getListTypeToCTypeMapping(): array
{
$ctypes = [
'blog_posts',
'blog_latestposts',
'blog_category',
'blog_authorposts',
'blog_tag',
'blog_archive',
'blog_sidebar',
'blog_commentform',
'blog_comments',
'blog_authors',
'blog_demandedposts',
'blog_relatedposts',
'blog_header',
'blog_footer'
];
return array_combine($ctypes, $ctypes);
}

public function getTitle(): string
{
return 'Migrate "t3g/blog" plugins to content elements.';
}

public function getDescription(): string
{
return 'The "blog" plugins will be registered as content elements. The update migrates existing records and backend user permissions.';
}
}
4 changes: 3 additions & 1 deletion Classes/ViewHelpers/CacheViewHelper.php
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

namespace T3G\AgencyPack\Blog\ViewHelpers;

use Psr\Http\Message\ServerRequestInterface;
use T3G\AgencyPack\Blog\Domain\Model\Post;
use T3G\AgencyPack\Blog\Service\CacheService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -25,7 +26,8 @@ public function initializeArguments(): void
public function render(): string
{
$post = $this->arguments['post'];
GeneralUtility::makeInstance(CacheService::class)->addTagsForPost($post);
$request = $this->renderingContext->getAttribute(ServerRequestInterface::class);
GeneralUtility::makeInstance(CacheService::class)->addTagsForPost($request, $post);

return '';
}
4 changes: 2 additions & 2 deletions Classes/ViewHelpers/Data/ContentListOptionsViewHelper.php
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ class ContentListOptionsViewHelper extends AbstractViewHelper
public function initializeArguments(): void
{
$this->registerArgument('as', 'string', 'Name of variable to create.');
// @todo renamee to CType
$this->registerArgument('listType', 'string', 'Plugin Type to Render', true);
}

@@ -33,8 +34,7 @@ public function render(): string
$listTypeConfiguration,
[
'uid' => Constants::LISTTYPE_TO_FAKE_UID_MAPPING[$arguments['listType']] ?? 0,
'list_type' => $arguments['listType'] ?? '',
'CType' => 'list',
'CType' => $arguments['listType'] ?? '',
'layout' => $listTypeConfiguration['layout'] ?? '0',
'frame_class' => $listTypeConfiguration['frame_class'] ?? 'default'
]
3 changes: 2 additions & 1 deletion Classes/ViewHelpers/Link/ArchiveViewHelper.php
Original file line number Diff line number Diff line change
@@ -58,9 +58,10 @@ public function render(): string
if ($month > 0) {
$arguments['month'] = $month;
}
$request = $this->renderingContext->getAttribute(ServerRequestInterface::class);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->reset()
->setRequest($this->renderingContext->getRequest())
->setRequest($request)
->setTargetPageUid($pageUid);
if ($rssFormat) {
$uriBuilder
3 changes: 2 additions & 1 deletion Classes/ViewHelpers/Link/AuthorViewHelper.php
Original file line number Diff line number Diff line change
@@ -68,9 +68,10 @@ protected function buildUriFromDefaultPage(Author $author, bool $rssFormat): str

protected function getUriBuilder(int $pageUid, array $additionalParams, bool $rssFormat): UriBuilder
{
$request = $this->renderingContext->getAttribute(ServerRequestInterface::class);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->reset()
->setRequest($this->renderingContext->getRequest())
->setRequest($request)
->setTargetPageUid($pageUid)
->setArguments($additionalParams);
if ($rssFormat) {
3 changes: 2 additions & 1 deletion Classes/ViewHelpers/Link/CategoryViewHelper.php
Original file line number Diff line number Diff line change
@@ -46,9 +46,10 @@ public function render(): string
$arguments = [
'category' => $category->getUid(),
];
$request = $this->renderingContext->getAttribute(ServerRequestInterface::class);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->reset()
->setRequest($this->renderingContext->getRequest())
->setRequest($request)
->setTargetPageUid($pageUid);
if ($rssFormat) {
$rssTypeNum = (int)(
4 changes: 3 additions & 1 deletion Classes/ViewHelpers/Link/PostViewHelper.php
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

namespace T3G\AgencyPack\Blog\ViewHelpers\Link;

use Psr\Http\Message\ServerRequestInterface;
use T3G\AgencyPack\Blog\Domain\Model\Post;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
@@ -41,8 +42,9 @@ public function render(): string
$pageUid = (int) $post->getUid();
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$createAbsoluteUri = (bool)$this->arguments['createAbsoluteUri'];
$request = $this->renderingContext->getAttribute(ServerRequestInterface::class);
$uri = $uriBuilder->reset()
->setRequest($this->renderingContext->getRequest())
->setRequest($request)
->setTargetPageUid($pageUid)
->setSection($section)
->setCreateAbsoluteUri($createAbsoluteUri)
3 changes: 2 additions & 1 deletion Classes/ViewHelpers/Link/TagViewHelper.php
Original file line number Diff line number Diff line change
@@ -46,9 +46,10 @@ public function render(): string
$arguments = [
'tag' => $tag->getUid(),
];
$request = $this->renderingContext->getAttribute(ServerRequestInterface::class);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->reset()
->setRequest($this->renderingContext->getRequest())
->setRequest($request)
->setTargetPageUid($pageUid);
if ($rssFormat) {
$rssTypeNum = (int)(
15 changes: 5 additions & 10 deletions Configuration/DataHandler/BlogSetupRecords.php
Original file line number Diff line number Diff line change
@@ -85,28 +85,23 @@
// Content elements
$data['tt_content']['NEW_ListOfPosts'] = [
'pid' => 'NEW_blogRoot',
'CType' => 'list',
'list_type' => 'blog_posts',
'CType' => 'blog_posts',
];
$data['tt_content']['NEW_ListByCategory'] = [
'pid' => 'NEW_blogCategoryPage',
'CType' => 'list',
'list_type' => 'blog_category',
'CType' => 'blog_category',
];
$data['tt_content']['NEW_ListByTag'] = [
'pid' => 'NEW_blogTagPage',
'CType' => 'list',
'list_type' => 'blog_tag',
'CType' => 'blog_tag',
];
$data['tt_content']['NEW_ListByAuthor'] = [
'pid' => 'NEW_blogAuthorPage',
'CType' => 'list',
'list_type' => 'blog_authorposts',
'CType' => 'blog_authorposts',
];
$data['tt_content']['NEW_ListByDate'] = [
'pid' => 'NEW_blogArchivePage',
'CType' => 'list',
'list_type' => 'blog_archive',
'CType' => 'blog_archive',
];

// Content
4 changes: 4 additions & 0 deletions Configuration/Sets/Integration/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: t3g/blog-integration
label: "TYPO3 Blog: Integration"
dependencies:
- t3g/blog-static
3 changes: 3 additions & 0 deletions Configuration/Sets/Shared/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: t3g/blog-shared
label: "TYPO3 Blog: shared"
hidden: true
File renamed without changes.
5 changes: 5 additions & 0 deletions Configuration/Sets/Standalone/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: t3g/blog-standalone
label: "TYPO3 Blog: Standalone"
dependencies:
- typo3/fluid-styled-content
- t3g/blog-static
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
######################
#### DEPENDENCIES ####
######################
@import "EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript"
@import "EXT:blog/Configuration/TypoScript/Static/setup.typoscript"
@import "EXT:blog/Configuration/TypoScript/Shared/setup.typoscript"

################################################
#### DYNAMIC CONTENT LIB FOR USAGE IN FLUID ####
################################################
Loading
Oops, something went wrong.