From 5fc922963e753be80e7901dcbd6d6c5545e21b9c Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 26 Jun 2024 13:51:45 +0200 Subject: [PATCH] Expose settings via `DateSearchVariables` Event --- Classes/Controller/DateController.php | 1 + .../Events/Controller/DateSearchVariables.php | 12 ++++++ Documentation/Changelog/3.8.0.rst | 27 ++++++++++++ .../Controller/DateSearchVariablesTest.php | 43 +++++++++++++++++++ ext_emconf.php | 2 +- 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 Documentation/Changelog/3.8.0.rst diff --git a/Classes/Controller/DateController.php b/Classes/Controller/DateController.php index eecb7e46..e071636a 100644 --- a/Classes/Controller/DateController.php +++ b/Classes/Controller/DateController.php @@ -133,6 +133,7 @@ public function searchAction(array $search = []): void } $event = $this->eventDispatcher->dispatch(new DateSearchVariables( + $this->settings, $search, $demand, $this->regionRepository->findAll(), diff --git a/Classes/Events/Controller/DateSearchVariables.php b/Classes/Events/Controller/DateSearchVariables.php index cbd68c4f..7058e67c 100644 --- a/Classes/Events/Controller/DateSearchVariables.php +++ b/Classes/Events/Controller/DateSearchVariables.php @@ -9,6 +9,11 @@ class DateSearchVariables { + /** + * @var array + */ + private $settings; + /** * @var array */ @@ -43,12 +48,14 @@ class DateSearchVariables * @param QueryResultInterface $regions */ public function __construct( + array $settings, array $search, DateDemand $demand, QueryResultInterface $regions, array $categories, array $features ) { + $this->settings = $settings; $this->search = $search; $this->demand = $demand; $this->regions = $regions; @@ -56,6 +63,11 @@ public function __construct( $this->features = $features; } + public function getSettings(): array + { + return $this->settings; + } + public function getSearch(): array { return $this->search; diff --git a/Documentation/Changelog/3.8.0.rst b/Documentation/Changelog/3.8.0.rst new file mode 100644 index 00000000..5ef18eaf --- /dev/null +++ b/Documentation/Changelog/3.8.0.rst @@ -0,0 +1,27 @@ +3.8.0 +===== + +Breaking +-------- + +Nothing + +Features +-------- + +* Expose settings via `DateSearchVariables` Event. + +Fixes +----- + +Nothing + +Tasks +----- + +Nothing + +Deprecation +----------- + +Nothing diff --git a/Tests/Unit/Events/Controller/DateSearchVariablesTest.php b/Tests/Unit/Events/Controller/DateSearchVariablesTest.php index dae8bd84..b2fb4314 100644 --- a/Tests/Unit/Events/Controller/DateSearchVariablesTest.php +++ b/Tests/Unit/Events/Controller/DateSearchVariablesTest.php @@ -23,6 +23,8 @@ class DateSearchVariablesTest extends TestCase public function canBeCreated(): void { $subject = new DateSearchVariables( + [ + ], [ ], new DateDemand(), @@ -37,12 +39,39 @@ public function canBeCreated(): void ); } + /** + * @test + */ + public function returnsInitializeSettings(): void + { + $subject = new DateSearchVariables( + [ + 'someCustomKey' => 'someCustomValue', + ], + [ + ], + new DateDemand(), + $this->prophesize(QueryResult::class)->reveal(), + [], + [] + ); + + self::assertSame( + [ + 'someCustomKey' => 'someCustomValue', + ], + $subject->getSettings() + ); + } + /** * @test */ public function returnsInitializeSearch(): void { $subject = new DateSearchVariables( + [ + ], [ 'executed' => '1', ], @@ -67,6 +96,8 @@ public function returnsInitializeDemand(): void { $demand = new DateDemand(); $subject = new DateSearchVariables( + [ + ], [ ], $demand, @@ -88,6 +119,8 @@ public function returnsInitialRegions(): void { $regions = $this->prophesize(QueryResult::class)->reveal(); $subject = new DateSearchVariables( + [ + ], [ ], new DateDemand(), @@ -108,6 +141,8 @@ public function returnsInitialRegions(): void public function returnsInitialCategories(): void { $subject = new DateSearchVariables( + [ + ], [ ], new DateDemand(), @@ -132,6 +167,8 @@ public function returnsInitialCategories(): void public function returnsInitialFeatures(): void { $subject = new DateSearchVariables( + [ + ], [ ], new DateDemand(), @@ -159,6 +196,8 @@ public function returnsInitialVariablesForView(): void $demand = new DateDemand(); $regions = $this->prophesize(QueryResult::class)->reveal(); $subject = new DateSearchVariables( + [ + ], [ 'executed' => '1', ], @@ -198,6 +237,8 @@ public function returnsVariablesForViewWithAddedVariables(): void $demand = new DateDemand(); $regions = $this->prophesize(QueryResult::class)->reveal(); $subject = new DateSearchVariables( + [ + ], [ 'executed' => '1', ], @@ -242,6 +283,8 @@ public function returnsVariablesForViewWithOverwrittenVariables(): void $demand = new DateDemand(); $regions = $this->prophesize(QueryResult::class)->reveal(); $subject = new DateSearchVariables( + [ + ], [ 'executed' => '1', ], diff --git a/ext_emconf.php b/ext_emconf.php index 0ad3069e..d55cbddd 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -9,7 +9,7 @@ 'state' => 'stable', 'createDirs' => '', 'clearCacheOnLoad' => 0, - 'version' => '3.7.0', + 'version' => '3.8.0', 'constraints' => [ 'depends' => [ 'typo3' => '10.4.00-11.5.99',