From 378f1e9167c5008b7c49f66fe3901f373620fc33 Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Fri, 24 Nov 2023 15:28:37 +0100 Subject: [PATCH 01/13] [TASK] Applied rector rules * DateTimeAspectInsteadOfGlobalsExecTimeRector (https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.0/Important-92736-ReturnTimestampAsIntegerInDateTimeAspect.html) * ExtEmConfRector (https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/ExtEmconf.html) * InjectAnnotationRector (https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.0/Feature-82869-ReplaceInjectWithTYPO3CMSExtbaseAnnotationInject.html) * ReplaceInjectAnnotationWithMethodRector (https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.0/Breaking-90799-DependencyInjectionWithNonPublicPropertiesHasBeenRemoved.html) * SubstituteConstantsModeAndRequestTypeRector (https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.0/Deprecation-92947-DeprecateTYPO3_MODEAndTYPO3_REQUESTTYPEConstants.html) --- Classes/EventListener/NewsListActionEventListener.php | 10 ++++++---- Classes/Hooks/EnrichDemandObject.php | 2 +- Classes/Hooks/FlexFormHook.php | 3 ++- Configuration/TCA/Overrides/tt_content.php | 2 +- ext_emconf.php | 1 - ext_localconf.php | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Classes/EventListener/NewsListActionEventListener.php b/Classes/EventListener/NewsListActionEventListener.php index fc02cbb..37b3543 100644 --- a/Classes/EventListener/NewsListActionEventListener.php +++ b/Classes/EventListener/NewsListActionEventListener.php @@ -4,6 +4,8 @@ namespace GeorgRinger\NewsFilter\EventListener; +use TYPO3\CMS\Core\Context\Context; +use GeorgRinger\News\Domain\Model\Dto\NewsDemand; use GeorgRinger\News\Domain\Repository\CategoryRepository; use GeorgRinger\News\Domain\Repository\TagRepository; use GeorgRinger\News\Event\NewsListActionEvent; @@ -33,14 +35,14 @@ public function __invoke(NewsListActionEvent $event) if ($settings['enableFilter'] ?? false) { $search = $this->objectManager->get(Search::class); - $vars = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('tx_news_pi1'); + $vars = GeneralUtility::_POST('tx_news_pi1'); if (isset($vars['search']) && is_array($vars['search'])) { /** @var Search $search */ $search = $this->objectManager->get(PropertyMapper::class)->convert($vars['search'], Search::class); } $extended = [ - 'currentDate' => $GLOBALS['EXEC_TIME'], + 'currentDate' => GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'), 'searchDemand' => $search, ]; @@ -90,7 +92,7 @@ protected function getAllRecordsByPid(string $tableName, string $pidList): array * * @param array $settings * @param string $class optional class which must be an instance of \GeorgRinger\News\Domain\Model\Dto\NewsDemand - * @return \GeorgRinger\News\Domain\Model\Dto\NewsDemand + * @return NewsDemand */ protected function createDemandObjectFromSettings( $settings, @@ -101,7 +103,7 @@ protected function createDemandObjectFromSettings( /* @var $demand \GeorgRinger\News\Domain\Model\Dto\NewsDemand */ $demand = $this->objectManager->get($class, $settings); - if (!$demand instanceof \GeorgRinger\News\Domain\Model\Dto\NewsDemand) { + if (!$demand instanceof NewsDemand) { throw new \UnexpectedValueException( sprintf('The demand object must be an instance of \GeorgRinger\\News\\Domain\\Model\\Dto\\NewsDemand, but %s given!', $class), diff --git a/Classes/Hooks/EnrichDemandObject.php b/Classes/Hooks/EnrichDemandObject.php index 9b4eb5c..65d7522 100644 --- a/Classes/Hooks/EnrichDemandObject.php +++ b/Classes/Hooks/EnrichDemandObject.php @@ -22,7 +22,7 @@ public function run(array &$params): void if ($settings['enableFilter']) { - $vars = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('tx_news_pi1'); + $vars = GeneralUtility::_POST('tx_news_pi1'); if (isset($vars['search']) && is_array($vars['search'])) { /** @var Search $search */ $search = $objectManager->get(PropertyMapper::class)->convert($vars['search'], Search::class); diff --git a/Classes/Hooks/FlexFormHook.php b/Classes/Hooks/FlexFormHook.php index 3d6ce49..dd586c0 100644 --- a/Classes/Hooks/FlexFormHook.php +++ b/Classes/Hooks/FlexFormHook.php @@ -2,6 +2,7 @@ namespace GeorgRinger\NewsFilter\Hooks; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Core\Environment; class FlexFormHook @@ -37,7 +38,7 @@ public function parseDataStructureByIdentifierPostProcess(array $dataStructure, $file = Environment::getPublicPath() . '/' . self::PATH; $content = file_get_contents($file); if ($content) { - $dataStructure['sheets']['extraEntryNewsFilter'] = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($content); + $dataStructure['sheets']['extraEntryNewsFilter'] = GeneralUtility::xml2array($content); } } return $dataStructure; diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 9e7c8c1..ed39536 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -1,5 +1,5 @@ 'Georg Ringer', 'author_email' => 'mail@ringer.it', 'state' => 'beta', - 'clearCacheOnLoad' => true, 'version' => '2.0.0', 'constraints' => [ 'depends' => [ diff --git a/ext_localconf.php b/ext_localconf.php index 60c656c..0f6ff7b 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,5 +1,5 @@ Date: Tue, 28 Nov 2023 10:20:50 +0100 Subject: [PATCH 02/13] Migrate from ObjectManager to Dependency Injection --- .../NewsListActionEventListener.php | 32 ++++++++++++------- Classes/Hooks/EnrichDemandObject.php | 12 +++++-- Configuration/Services.yaml | 9 ++++++ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Classes/EventListener/NewsListActionEventListener.php b/Classes/EventListener/NewsListActionEventListener.php index 37b3543..51d6c40 100644 --- a/Classes/EventListener/NewsListActionEventListener.php +++ b/Classes/EventListener/NewsListActionEventListener.php @@ -19,12 +19,24 @@ class NewsListActionEventListener { - /** @var ObjectManager */ - protected $objectManager; + /** @var CategoryRepository */ + protected $categoryRepository; - public function __construct() + /** @var TagRepository */ + protected $tagRepository; + + /** @var PropertyMapper */ + protected $propertyMapper; + + public function __construct( + CategoryRepository $categoryRepository, + TagRepository $tagRepository, + PropertyMapper $propertyMapper + ) { - $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); + $this->categoryRepository = $categoryRepository; + $this->tagRepository = $tagRepository; + $this->propertyMapper = $propertyMapper; } public function __invoke(NewsListActionEvent $event) @@ -33,12 +45,12 @@ public function __invoke(NewsListActionEvent $event) $settings = $data['settings']; if ($settings['enableFilter'] ?? false) { - $search = $this->objectManager->get(Search::class); + $search = GeneralUtility::makeInstance(Search::class); $vars = GeneralUtility::_POST('tx_news_pi1'); if (isset($vars['search']) && is_array($vars['search'])) { /** @var Search $search */ - $search = $this->objectManager->get(PropertyMapper::class)->convert($vars['search'], Search::class); + $search = $this->propertyMapper->convert($vars['search'], Search::class); } $extended = [ @@ -48,14 +60,12 @@ public function __invoke(NewsListActionEvent $event) $categories2 = $this->getAllRecordsByPid('sys_category', $settings['filterCategories']); if (!empty($categories2)) { - $categoryRepository = $this->objectManager->get(CategoryRepository::class); - $extended['categories'] = $categoryRepository->findByIdListWithLanguageSupport($categories2); + $extended['categories'] = $this->categoryRepository->findByIdListWithLanguageSupport($categories2); } $tags2 = $this->getAllRecordsByPid('tx_news_domain_model_tag', $settings['filterTags']); if (!empty($tags2)) { - $tagRepository = $this->objectManager->get(TagRepository::class); - $extended['tags'] = $tagRepository->findByIdList($tags2); + $extended['tags'] = $this->tagRepository->findByIdList($tags2); } $data['extendedVariables'] = $extended; @@ -102,7 +112,7 @@ protected function createDemandObjectFromSettings( $class = isset($settings['demandClass']) && !empty($settings['demandClass']) ? $settings['demandClass'] : $class; /* @var $demand \GeorgRinger\News\Domain\Model\Dto\NewsDemand */ - $demand = $this->objectManager->get($class, $settings); + $demand = GeneralUtility::makeInstance($class, $settings); if (!$demand instanceof NewsDemand) { throw new \UnexpectedValueException( sprintf('The demand object must be an instance of \GeorgRinger\\News\\Domain\\Model\\Dto\\NewsDemand, but %s given!', diff --git a/Classes/Hooks/EnrichDemandObject.php b/Classes/Hooks/EnrichDemandObject.php index 65d7522..4254c27 100644 --- a/Classes/Hooks/EnrichDemandObject.php +++ b/Classes/Hooks/EnrichDemandObject.php @@ -11,6 +11,14 @@ class EnrichDemandObject { + /** @var PropertyMapper */ + protected $propertyMapper; + + public function __construct(PropertyMapper $propertyMapper) + { + $this->propertyMapper = $propertyMapper; + } + public function run(array &$params): void { $demand = $params['demand']; @@ -18,14 +26,12 @@ public function run(array &$params): void return; } $settings = $params['settings']; - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - if ($settings['enableFilter']) { $vars = GeneralUtility::_POST('tx_news_pi1'); if (isset($vars['search']) && is_array($vars['search'])) { /** @var Search $search */ - $search = $objectManager->get(PropertyMapper::class)->convert($vars['search'], Search::class); + $search = $this->propertyMapper->convert($vars['search'], Search::class); $demand->setFilteredCategories($search->getFilteredCategories()); $demand->setFilteredTags($search->getFilteredTags()); diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 11ad4e8..d94f781 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -1,5 +1,14 @@ services: + _defaults: + autowire: true + autoconfigure: true + public: false + + GeorgRinger\NewsFilter\Hooks\EnrichDemandObject: + public: true + GeorgRinger\NewsFilter\EventListener\NewsListActionEventListener: + public: true tags: - name: event.listener identifier: 'newslist-manipulation' From 664877034af578145328cd04468a33629f55c20c Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Wed, 29 Nov 2023 11:58:39 +0100 Subject: [PATCH 03/13] Raise version constraints --- composer.json | 4 ++-- ext_emconf.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index db8ebd9..645da9e 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,8 @@ "homepage": "https://ringer.it", "license": ["GPL-2.0-or-later"], "require": { - "typo3/cms-core": "^10.4 || ^11.5", - "georgringer/news": "^9 || ^10" + "typo3/cms-core": "^10.4 || ^11.5 || ^12.4", + "georgringer/news": "^9 || ^10 || ^11" }, "autoload": { "psr-4": { diff --git a/ext_emconf.php b/ext_emconf.php index 6bf0cc3..c80887d 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -10,8 +10,8 @@ 'version' => '2.0.0', 'constraints' => [ 'depends' => [ - 'typo3' => '10.4.0-11.5.99', - 'news' => '9.0.0-10.99.99', + 'typo3' => '10.4.0-12.4.99', + 'news' => '9.0.0-11.99.99', ], 'conflicts' => [], 'suggests' => [], From 4a1c4529c9e0717f6076e01f4b67c47526ae4121 Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Wed, 29 Nov 2023 13:13:09 +0100 Subject: [PATCH 04/13] Migrate flexform hook to new CTypes This drops support for EXT:news < 10 and TYPO3 < 11.5 --- Classes/Hooks/FlexFormHook.php | 43 ++++++++-------- .../FlexForms/flexform_newsfilter.xml | 8 +-- .../FlexForms/flexform_newsfilter12.xml | 49 +++++++++++++++++++ Configuration/Services.yaml | 10 +++- ext_emconf.php | 4 +- 5 files changed, 84 insertions(+), 30 deletions(-) create mode 100644 Configuration/FlexForms/flexform_newsfilter12.xml diff --git a/Classes/Hooks/FlexFormHook.php b/Classes/Hooks/FlexFormHook.php index dd586c0..1989913 100644 --- a/Classes/Hooks/FlexFormHook.php +++ b/Classes/Hooks/FlexFormHook.php @@ -2,31 +2,29 @@ namespace GeorgRinger\NewsFilter\Hooks; +use TYPO3\CMS\Core\Configuration\Event\AfterFlexFormDataStructureParsedEvent; +use TYPO3\CMS\Core\Information\Typo3Version; +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Core\Environment; class FlexFormHook { + private const CTYPES = ['*,news_pi1', '*,news_newsliststicky']; - const PATH = 'typo3conf/ext/news_filter/Configuration/FlexForms/flexform_newsfilter.xml'; - - // For 7x - - /** - * @param array $dataStructArray - * @param array $conf - * @param array $row - * @param string $table - */ - public function getFlexFormDS_postProcessDS(&$dataStructArray, $conf, $row, $table) + public function __invoke(AfterFlexFormDataStructureParsedEvent $event): void { - if ($table === 'tt_content' && $row['CType'] === 'list' && $row['list_type'] === 'news_pi1') { - $dataStructArray['sheets']['extraEntryNewsFilter'] = self::PATH; + $dataStructure = $event->getDataStructure(); + $identifier = $event->getIdentifier(); + + if ($identifier['type'] === 'tca' && $identifier['tableName'] === 'tt_content' && in_array($identifier['dataStructureKey'], self::CTYPES)) { + $content = file_get_contents($this->getPath()); + if ($content) { + $dataStructure['sheets']['extraEntryEventNews'] = GeneralUtility::xml2array($content); + } } + $event->setDataStructure($dataStructure); } - // For 8x - /** * @param array $dataStructure * @param array $identifier @@ -34,13 +32,18 @@ public function getFlexFormDS_postProcessDS(&$dataStructArray, $conf, $row, $tab */ public function parseDataStructureByIdentifierPostProcess(array $dataStructure, array $identifier): array { - if ($identifier['type'] === 'tca' && $identifier['tableName'] === 'tt_content' && $identifier['dataStructureKey'] === 'news_pi1,list') { - $file = Environment::getPublicPath() . '/' . self::PATH; - $content = file_get_contents($file); + if ($identifier['type'] === 'tca' && $identifier['tableName'] === 'tt_content' && in_array($identifier['dataStructureKey'], self::CTYPES)) { + $content = file_get_contents($this->getPath()); if ($content) { $dataStructure['sheets']['extraEntryNewsFilter'] = GeneralUtility::xml2array($content); } } return $dataStructure; } -} \ No newline at end of file + + protected function getPath(): string + { + $file = (new Typo3Version())->getMajorVersion() >= 12 ? 'flexform_newsfilter12.xml' : 'flexform_newsfilter.xml'; + return ExtensionManagementUtility::extPath('news_filter') . 'Configuration/FlexForms/' . $file; + } +} diff --git a/Configuration/FlexForms/flexform_newsfilter.xml b/Configuration/FlexForms/flexform_newsfilter.xml index a3f796f..ba77d99 100644 --- a/Configuration/FlexForms/flexform_newsfilter.xml +++ b/Configuration/FlexForms/flexform_newsfilter.xml @@ -1,12 +1,8 @@ - - NewsFilter - + NewsFilter array - - @@ -48,4 +44,4 @@ - \ No newline at end of file + diff --git a/Configuration/FlexForms/flexform_newsfilter12.xml b/Configuration/FlexForms/flexform_newsfilter12.xml new file mode 100644 index 0000000..2b86d25 --- /dev/null +++ b/Configuration/FlexForms/flexform_newsfilter12.xml @@ -0,0 +1,49 @@ + + + + NewsFilter + + array + + + + + + check + 0 + + + + + + + + + + group + db + pages + 2 + 50 + 0 + + + + + + + + + + group + db + pages + 2 + 50 + 0 + + + + + + diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index d94f781..94ef2d4 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -11,5 +11,11 @@ services: public: true tags: - name: event.listener - identifier: 'newslist-manipulation' - event: GeorgRinger\News\Event\NewsListActionEvent \ No newline at end of file + identifier: 'news_filter-manipulation' + event: GeorgRinger\News\Event\NewsListActionEvent + + GeorgRinger\NewsFilter\Hooks\FlexFormHook: + tags: + - name: event.listener + identifier: 'news_filter-flexformhook' + event: TYPO3\CMS\Core\Configuration\Event\AfterFlexFormDataStructureParsedEvent \ No newline at end of file diff --git a/ext_emconf.php b/ext_emconf.php index c80887d..b91d732 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -10,8 +10,8 @@ 'version' => '2.0.0', 'constraints' => [ 'depends' => [ - 'typo3' => '10.4.0-12.4.99', - 'news' => '9.0.0-11.99.99', + 'typo3' => '11.5.0-12.4.99', + 'news' => '11.0.0-11.99.99', ], 'conflicts' => [], 'suggests' => [], From 84d9cbd00e94ec53428650237894e1731bdb787e Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Wed, 29 Nov 2023 13:19:34 +0100 Subject: [PATCH 05/13] Add xlf file for flexform translations --- Configuration/FlexForms/flexform_newsfilter.xml | 2 +- Resources/Private/Language/locallang_ff.xlf | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 Resources/Private/Language/locallang_ff.xlf diff --git a/Configuration/FlexForms/flexform_newsfilter.xml b/Configuration/FlexForms/flexform_newsfilter.xml index ba77d99..8987ca9 100644 --- a/Configuration/FlexForms/flexform_newsfilter.xml +++ b/Configuration/FlexForms/flexform_newsfilter.xml @@ -5,7 +5,7 @@ - + check 0 diff --git a/Resources/Private/Language/locallang_ff.xlf b/Resources/Private/Language/locallang_ff.xlf new file mode 100644 index 0000000..8924d3b --- /dev/null +++ b/Resources/Private/Language/locallang_ff.xlf @@ -0,0 +1,11 @@ + + + +
+ + + Enable filter + + + + From c47a83ee08bc51e409a0e22d74ebdb847f05f026 Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Wed, 29 Nov 2023 15:39:59 +0100 Subject: [PATCH 06/13] FIX: search isn't working Resolves: #13 --- Classes/Hooks/EnrichDemandObject.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Classes/Hooks/EnrichDemandObject.php b/Classes/Hooks/EnrichDemandObject.php index 4254c27..f01ffb4 100644 --- a/Classes/Hooks/EnrichDemandObject.php +++ b/Classes/Hooks/EnrichDemandObject.php @@ -27,17 +27,18 @@ public function run(array &$params): void } $settings = $params['settings']; - if ($settings['enableFilter']) { + if ($settings['enableFilter'] ?? false) { $vars = GeneralUtility::_POST('tx_news_pi1'); if (isset($vars['search']) && is_array($vars['search'])) { /** @var Search $search */ $search = $this->propertyMapper->convert($vars['search'], Search::class); - + $search->setFields($settings['search']['fields']); + $search->setSplitSubjectWords((bool)$settings['search']['splitSearchWord']); + $demand->setSearch($search); $demand->setFilteredCategories($search->getFilteredCategories()); $demand->setFilteredTags($search->getFilteredTags()); $demand->setFromDate($search->getFromDate()); $demand->setToDate($search->getToDate()); - } } } From 92c5d6e3ab8ea8146cd1d16cee2542c3f5262cab Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Thu, 7 Dec 2023 17:33:47 +0100 Subject: [PATCH 07/13] FIX: flexform syntax for v11 and v12 https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Deprecation-97126-TCEformsRemovedInFlexForm.html --- .../FlexForms/flexform_newsfilter.xml | 4 +- .../FlexForms/flexform_newsfilter12.xml | 56 ++++++++----------- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/Configuration/FlexForms/flexform_newsfilter.xml b/Configuration/FlexForms/flexform_newsfilter.xml index 8987ca9..f78c96b 100644 --- a/Configuration/FlexForms/flexform_newsfilter.xml +++ b/Configuration/FlexForms/flexform_newsfilter.xml @@ -1,6 +1,8 @@ - NewsFilter + + NewsFilter + array diff --git a/Configuration/FlexForms/flexform_newsfilter12.xml b/Configuration/FlexForms/flexform_newsfilter12.xml index 2b86d25..4704605 100644 --- a/Configuration/FlexForms/flexform_newsfilter12.xml +++ b/Configuration/FlexForms/flexform_newsfilter12.xml @@ -1,48 +1,40 @@ - - NewsFilter - + NewsFilter array - - - - check - 0 - - + + + check + 0 + - - - - group - db - pages - 2 - 50 - 0 - - + + + group + db + pages + 2 + 50 + 0 + - - - - group - db - pages - 2 - 50 - 0 - - + + + group + db + pages + 2 + 50 + 0 + From 5c50b02642a684d1befb6502a19210057d0e9831 Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Fri, 8 Dec 2023 15:06:36 +0100 Subject: [PATCH 08/13] Cleanup --- Classes/Domain/Model/Dto/Demand.php | 2 +- Classes/Domain/Model/Dto/Search.php | 4 +--- .../Domain/Repository/CategoryRepository.php | 11 ++++----- .../NewsListActionEventListener.php | 24 ++++++++++--------- Classes/Hooks/EnrichDemandObject.php | 2 +- Classes/Hooks/Repository.php | 2 -- Configuration/TCA/Overrides/tt_content.php | 3 ++- ext_localconf.php | 1 + 8 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Classes/Domain/Model/Dto/Demand.php b/Classes/Domain/Model/Dto/Demand.php index 79f079d..0bc0f2d 100644 --- a/Classes/Domain/Model/Dto/Demand.php +++ b/Classes/Domain/Model/Dto/Demand.php @@ -1,4 +1,5 @@ filteredCategories = $filteredCategories; } - -} \ No newline at end of file +} diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index 8435785..15f2f39 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -2,9 +2,8 @@ namespace GeorgRinger\NewsFilter\Domain\Repository; -class CategoryRepository extends \GeorgRinger\News\Domain\Repository\CategoryRepository { - - +class CategoryRepository extends \GeorgRinger\News\Domain\Repository\CategoryRepository +{ /** * Find categories by a given pid * @@ -36,7 +35,7 @@ public function findByIdListWithLanguageSupport(array $idList, array $ordering = return $query->matching( $query->logicalAnd( $conditions - ))->execute(); + ) + )->execute(); } - -} \ No newline at end of file +} diff --git a/Classes/EventListener/NewsListActionEventListener.php b/Classes/EventListener/NewsListActionEventListener.php index 51d6c40..808c25a 100644 --- a/Classes/EventListener/NewsListActionEventListener.php +++ b/Classes/EventListener/NewsListActionEventListener.php @@ -4,17 +4,16 @@ namespace GeorgRinger\NewsFilter\EventListener; -use TYPO3\CMS\Core\Context\Context; use GeorgRinger\News\Domain\Model\Dto\NewsDemand; use GeorgRinger\News\Domain\Repository\CategoryRepository; use GeorgRinger\News\Domain\Repository\TagRepository; use GeorgRinger\News\Event\NewsListActionEvent; use GeorgRinger\News\Utility\Page; use GeorgRinger\NewsFilter\Domain\Model\Dto\Search; +use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Property\PropertyMapper; class NewsListActionEventListener @@ -32,8 +31,7 @@ public function __construct( CategoryRepository $categoryRepository, TagRepository $tagRepository, PropertyMapper $propertyMapper - ) - { + ) { $this->categoryRepository = $categoryRepository; $this->tagRepository = $tagRepository; $this->propertyMapper = $propertyMapper; @@ -107,17 +105,19 @@ protected function getAllRecordsByPid(string $tableName, string $pidList): array protected function createDemandObjectFromSettings( $settings, $class = 'GeorgRinger\\News\\Domain\\Model\\Dto\\NewsDemand' - ) - { + ) { $class = isset($settings['demandClass']) && !empty($settings['demandClass']) ? $settings['demandClass'] : $class; /* @var $demand \GeorgRinger\News\Domain\Model\Dto\NewsDemand */ $demand = GeneralUtility::makeInstance($class, $settings); if (!$demand instanceof NewsDemand) { throw new \UnexpectedValueException( - sprintf('The demand object must be an instance of \GeorgRinger\\News\\Domain\\Model\\Dto\\NewsDemand, but %s given!', - $class), - 1423157953); + sprintf( + 'The demand object must be an instance of \GeorgRinger\\News\\Domain\\Model\\Dto\\NewsDemand, but %s given!', + $class + ), + 1423157953 + ); } $demand->setCategories(GeneralUtility::trimExplode(',', $settings['categories'], true)); @@ -147,8 +147,10 @@ protected function createDemandObjectFromSettings( $demand->setMonth((int)$settings['month']); $demand->setYear((int)$settings['year']); - $demand->setStoragePage(Page::extendPidListByChildren($settings['startingpoint'], - $settings['recursive'])); + $demand->setStoragePage(Page::extendPidListByChildren( + $settings['startingpoint'], + $settings['recursive'] + )); return $demand; } } diff --git a/Classes/Hooks/EnrichDemandObject.php b/Classes/Hooks/EnrichDemandObject.php index f01ffb4..874b32f 100644 --- a/Classes/Hooks/EnrichDemandObject.php +++ b/Classes/Hooks/EnrichDemandObject.php @@ -1,4 +1,5 @@ logicalOr($tagConstraint); } - } } diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index ed39536..242b87c 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -1,4 +1,5 @@ Date: Tue, 23 Jan 2024 20:51:10 +0100 Subject: [PATCH 09/13] Migrate to match hardened logicalAnd/Or in v12 https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-96044-HardenMethodSignatureOfLogicalAndAndLogicalOr.html --- Classes/Domain/Repository/CategoryRepository.php | 2 +- Classes/Hooks/Repository.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index 15f2f39..0e38e8f 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -34,7 +34,7 @@ public function findByIdListWithLanguageSupport(array $idList, array $ordering = return $query->matching( $query->logicalAnd( - $conditions + ...$conditions ) )->execute(); } diff --git a/Classes/Hooks/Repository.php b/Classes/Hooks/Repository.php index 88b1672..5c1da58 100644 --- a/Classes/Hooks/Repository.php +++ b/Classes/Hooks/Repository.php @@ -48,7 +48,7 @@ protected function updateConstraints(Demand $demand, QueryInterface $query, arra foreach ($categories as $category) { $categoryConstraint[] = $query->contains('categories', $category); } - $constraints['filteredCategories'] = $query->logicalOr($categoryConstraint); + $constraints['filteredCategories'] = $query->logicalOr(...$categoryConstraint); } // tags @@ -58,7 +58,7 @@ protected function updateConstraints(Demand $demand, QueryInterface $query, arra foreach ($tags as $tag) { $tagConstraint[] = $query->contains('tags', $tag); } - $constraints['filteredTags'] = $query->logicalOr($tagConstraint); + $constraints['filteredTags'] = $query->logicalOr(...$tagConstraint); } } } From af05bb8b4a38a4a9d4af53c8dee1fb74db7a5905 Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Tue, 23 Jan 2024 21:01:36 +0100 Subject: [PATCH 10/13] Bumped constraints, updated README --- Readme.md => README.md | 14 +++++++------- composer.json | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) rename Readme.md => README.md (91%) diff --git a/Readme.md b/README.md similarity index 91% rename from Readme.md rename to README.md index 066a1a3..89282e0 100644 --- a/Readme.md +++ b/README.md @@ -5,19 +5,20 @@ This extension makes it possible to filter news in the frontend by the following - date from & to - categories - tags +- sword This extension has been sponsored by [University Basel](https://www.unibas.ch) ## Requirements -- TYPO3 10.4 -- news 9.x +- TYPO3 11.5 or 12.4 +- EXT:news 11.x ## Usage 1. Install the extension just as any other extension. Either use the Extension Manager or composer and `composer require georgringer/news-filter`. -2. Select the action "list" in the news plugin and activate the additional checkbox "Enable filter" -3. Select page of categories & tags. +2. Select the action "list" in the news plugin and activate the additional checkbox "Enable filter". +3. Select folders containing categories & tags. ### TypoScript @@ -29,9 +30,9 @@ plugin.tx_news.settings.demandClass = GeorgRinger\NewsFilter\Domain\Model\Dto\De ### Templating -Add the following part to your `List.html`: +Add the following part to your `News/List.html`: -``` +```xml
@@ -76,4 +77,3 @@ Add the following part to your `List.html`:
``` - diff --git a/composer.json b/composer.json index 645da9e..6aa3d69 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,8 @@ "homepage": "https://ringer.it", "license": ["GPL-2.0-or-later"], "require": { - "typo3/cms-core": "^10.4 || ^11.5 || ^12.4", - "georgringer/news": "^9 || ^10 || ^11" + "typo3/cms-core": "^11.5 || ^12.4", + "georgringer/news": "^11.0" }, "autoload": { "psr-4": { From 069a2b2bb79bc94659dc10e2cf04c983aa5ffd5d Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Tue, 23 Jan 2024 21:41:59 +0100 Subject: [PATCH 11/13] FIX: caching issue for CType 'news_newsliststicky' --- ext_localconf.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext_localconf.php b/ext_localconf.php index 6f04773..baf2039 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -9,7 +9,8 @@ $vars = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('tx_news_pi1'); if (isset($vars['search']) && is_array($vars['search'])) { - $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['News']['plugins']['Pi1']['controllers'][\GeorgRinger\News\Controller\NewsController::class]['nonCacheableActions'][] = 'list'; + foreach (['Pi1', 'NewsListSticky', 'NewsSelectedList'] as $pluginName) + $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['News']['plugins'][$pluginName]['controllers'][\GeorgRinger\News\Controller\NewsController::class]['nonCacheableActions'][] = 'list'; } $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['classes']['Domain/Repository/CategoryRepository'][] = 'news_filter'; From 8e45d83baa87d9502793217ff6175fda4fe60fad Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Tue, 23 Jan 2024 21:44:56 +0100 Subject: [PATCH 12/13] FIX: typo --- Classes/Hooks/FlexFormHook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Hooks/FlexFormHook.php b/Classes/Hooks/FlexFormHook.php index 1989913..be3421a 100644 --- a/Classes/Hooks/FlexFormHook.php +++ b/Classes/Hooks/FlexFormHook.php @@ -19,7 +19,7 @@ public function __invoke(AfterFlexFormDataStructureParsedEvent $event): void if ($identifier['type'] === 'tca' && $identifier['tableName'] === 'tt_content' && in_array($identifier['dataStructureKey'], self::CTYPES)) { $content = file_get_contents($this->getPath()); if ($content) { - $dataStructure['sheets']['extraEntryEventNews'] = GeneralUtility::xml2array($content); + $dataStructure['sheets']['extraEntryNewsFilter'] = GeneralUtility::xml2array($content); } } $event->setDataStructure($dataStructure); From e2d7514c764d0f25ed5590f00dd9758cff3fb930 Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Tue, 23 Jan 2024 21:47:35 +0100 Subject: [PATCH 13/13] Cleanup --- ext_localconf.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ext_localconf.php b/ext_localconf.php index baf2039..7b66a12 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -15,11 +15,6 @@ $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['classes']['Domain/Repository/CategoryRepository'][] = 'news_filter'; -// For 7x -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getFlexFormDSClass']['news_filter'] - = \GeorgRinger\NewsFilter\Hooks\FlexFormHook::class; - -// For 8x $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class]['flexParsing']['news_filter'] = \GeorgRinger\NewsFilter\Hooks\FlexFormHook::class;