-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from okmiim/task/update
Add support for TYPO3 v12 and calendarize 13
- Loading branch information
Showing
20 changed files
with
326 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace HDNET\CalendarizeNews\EventListener; | ||
|
||
use TYPO3\CMS\Core\Configuration\Event\AfterFlexFormDataStructureParsedEvent; | ||
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools; | ||
use TYPO3\CMS\Core\Utility\ArrayUtility; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* This adds additional flexform configurations to calendarize. | ||
* In this case a field for the news PID. | ||
*/ | ||
final class ModifyFlexformEvent | ||
{ | ||
public function __invoke(AfterFlexFormDataStructureParsedEvent $event) | ||
{ | ||
$identifier = $event->getIdentifier(); | ||
if ( | ||
'tca' === ($identifier['type'] ?? '') | ||
&& 'tt_content' === ($identifier['tableName'] ?? '') | ||
&& str_starts_with($identifier['dataStructureKey'] ?? '', 'calendarize_') | ||
) { | ||
$file = GeneralUtility::getFileAbsFileName('EXT:calendarize_news/Configuration/FlexForms/Calendar.xml'); | ||
$content = file_get_contents($file); | ||
if ($content) { | ||
$overwrite = GeneralUtility::xml2array($content); | ||
// Deprecated: remove when dropping TYPO3 v11 support and remove TCEforms & internal_type in Calendar.xml | ||
$flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class); | ||
$overwrite = $flexFormTools->removeElementTceFormsRecursive($overwrite); | ||
|
||
if (\is_array($overwrite)) { | ||
$parsedDataStructure = $event->getDataStructure(); | ||
ArrayUtility::mergeRecursiveWithOverrule($parsedDataStructure, $overwrite); | ||
$event->setDataStructure($parsedDataStructure); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: True | ||
public: false | ||
|
||
HDNET\CalendarizeNews\: | ||
resource: '../Classes/*' | ||
# TODO: see https://github.com/lochmueller/calendarize_news/issues/46 | ||
exclude: | ||
- '../Classes/Persistence' | ||
- '../Classes/Xclass/{NewsRepository,NewsController.php}' | ||
|
||
HDNET\CalendarizeNews\EventListener\ModifyFlexformEvent: | ||
tags: | ||
- name: event.listener | ||
identifier: 'calendarize-news/modify-flexform' | ||
event: TYPO3\CMS\Core\Configuration\Event\AfterFlexFormDataStructureParsedEvent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
defined('TYPO3') or exit(); | ||
|
||
\HDNET\Calendarize\Register::createTcaConfiguration(\HDNET\CalendarizeNews\Register::getConfiguration()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Partials for BE module | ||
templates.lochmueller/calendarize.1700776845 = lochmueller/calendarize-news:Resources/Private/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"tx_news_domain_model_news" | ||
,"uid","pid","type","title","calendarize" | ||
,10,1,0,"NormalNews", | ||
,20,1,0,"WithCalendarizeConfiguration",21 | ||
|
||
"tx_calendarize_domain_model_configuration" | ||
,"uid","pid","type","handling","start_date","all_day","t3ver_oid","t3ver_wsid","t3ver_state" | ||
,21,1,"time","include","2026-05-02",1,0,0,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd" | ||
backupGlobals="true" | ||
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" | ||
cacheResult="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
convertDeprecationsToExceptions="false" | ||
convertNoticesToExceptions="true" | ||
forceCoversAnnotation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
stopOnIncomplete="false" | ||
stopOnSkipped="false" | ||
verbose="false" | ||
beStrictAboutTestsThatDoNotTestAnything="false" | ||
failOnWarning="true" | ||
failOnRisky="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Functional tests"> | ||
<!-- | ||
This path either needs an adaption in extensions, or an extension's | ||
test location path needs to be given to phpunit. | ||
--> | ||
<directory suffix="Test.php">./</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<!-- @deprecated: will be removed with next major version, constant TYPO3_MODE is deprecated --> | ||
<const name="TYPO3_MODE" value="BE" /> | ||
<!-- | ||
@deprecated: Set this to not suppress warnings, notices and deprecations in functional tests | ||
with TYPO3 core v11 and up. | ||
Will always be done with next major version. | ||
To still suppress warnings, notices and deprecations, do NOT define the constant at all. | ||
--> | ||
<const name="TYPO3_TESTING_FUNCTIONAL_REMOVE_ERROR_HANDLER" value="true" /> | ||
<ini name="display_errors" value="1" /> | ||
<env name="TYPO3_CONTEXT" value="Testing" /> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace HDNET\CalendarizeNews\Tests\Functional; | ||
|
||
use HDNET\Calendarize\Service\IndexerService; | ||
use TYPO3\CMS\Core\Database\ConnectionPool; | ||
use TYPO3\CMS\Core\Information\Typo3Version; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
class NewsIndexTest extends FunctionalTestCase | ||
{ | ||
public function __construct() | ||
{ | ||
// Initialize inside constructor to support TYPO3 v10 | ||
$this->coreExtensionsToLoad = ['extbase', 'fluid']; | ||
$this->testExtensionsToLoad = ['typo3conf/ext/news', 'typo3conf/ext/calendarize', 'typo3conf/ext/calendarize_news']; | ||
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 12) { | ||
array_splice($this->testExtensionsToLoad, 1, 0, 'typo3conf/ext/autoloader'); | ||
} | ||
parent::__construct(); | ||
} | ||
|
||
public function testNewsIndexing(): void | ||
{ | ||
$this->importCSVDataSet(__DIR__ . "/Fixtures/News.csv"); | ||
|
||
/** @var IndexerService $indexerService */ | ||
$indexerService = GeneralUtility::makeInstance(IndexerService::class); | ||
$indexerService->reindexAll(); | ||
|
||
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) | ||
->getQueryBuilderForTable('tx_calendarize_domain_model_index'); | ||
|
||
$rows = $queryBuilder | ||
->select('*') | ||
->from('tx_calendarize_domain_model_index') | ||
->execute()->fetchAllAssociative(); | ||
|
||
self::assertCount(1, $rows); | ||
self::assertEquals(20, $rows[0]['foreign_uid']); | ||
self::assertEquals('2026-05-02', $rows[0]['start_date']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace HDNET\CalendarizeNews\Tests\Functional\Xclass; | ||
|
||
use TYPO3\CMS\Fluid\View\StandaloneView; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
class NewsLinkViewHelperTest extends FunctionalTestCase | ||
{ | ||
public function __construct() | ||
{ | ||
// Initialize inside constructor to support TYPO3 v10 | ||
$this->coreExtensionsToLoad = ['extbase', 'fluid']; | ||
$this->testExtensionsToLoad = ['typo3conf/ext/news', 'typo3conf/ext/calendarize_news']; | ||
parent::__construct(); | ||
} | ||
|
||
public function testViewHelperRender(): void | ||
{ | ||
$view = new StandaloneView(); | ||
$template = '{namespace n=GeorgRinger\News\ViewHelpers}' . | ||
'<n:link newsItem="{news}">MyLink</n:link>'; | ||
|
||
$view->setTemplateSource($template); | ||
$view->assign('news', null); | ||
|
||
self::assertEquals('MyLink', $view->render()); | ||
} | ||
|
||
public function testXclassLoadedAndIndexArgumentIsAccepted(): void | ||
{ | ||
$view = new StandaloneView(); | ||
$template = '{namespace n=GeorgRinger\News\ViewHelpers}' . | ||
'<n:link newsItem="{news}" index="{index}">MyLink</n:link>'; | ||
|
||
$view->setTemplateSource($template); | ||
$view->assign('news', null); | ||
$view->assign('index', null); | ||
|
||
self::assertEquals('MyLink', $view->render()); | ||
} | ||
|
||
public function testIndexId(): void | ||
{ | ||
$view = new StandaloneView(); | ||
$template = '{namespace n=GeorgRinger\News\ViewHelpers}' . | ||
'<n:link newsItem="{news}" index="{index}">MyLink</n:link>'; | ||
|
||
$view->setTemplateSource($template); | ||
$view->assign('news', null); | ||
$view->assign('index', 22); | ||
|
||
self::assertEquals('MyLink', $view->render()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.