From 2168412ae5d1da97ec423ec7c8c9858230c400c7 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Jun 2024 10:09:26 +0200 Subject: [PATCH] Expose settings via `DateSearchVariables` Event (#58) --- Classes/Controller/DateController.php | 1 + .../Events/Controller/DateSearchVariables.php | 6 +++ Documentation/Changelog/3.8.0.rst | 27 ++++++++++++ .../Controller/DateSearchVariablesTest.php | 41 +++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 Documentation/Changelog/3.8.0.rst diff --git a/Classes/Controller/DateController.php b/Classes/Controller/DateController.php index 1e90b7a..37c6fce 100644 --- a/Classes/Controller/DateController.php +++ b/Classes/Controller/DateController.php @@ -83,6 +83,7 @@ final class DateController extends AbstractController } $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 ba2dd10..09af86d 100644 --- a/Classes/Events/Controller/DateSearchVariables.php +++ b/Classes/Events/Controller/DateSearchVariables.php @@ -19,6 +19,7 @@ final class DateSearchVariables * @param array $features */ public function __construct( + private readonly array $settings, private readonly array $search, private readonly DateDemand $demand, private readonly QueryResultInterface $regions, @@ -27,6 +28,11 @@ final class DateSearchVariables ) { } + 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 0000000..5ef18ea --- /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 ba2213a..cd82f1f 100644 --- a/Tests/Unit/Events/Controller/DateSearchVariablesTest.php +++ b/Tests/Unit/Events/Controller/DateSearchVariablesTest.php @@ -16,6 +16,8 @@ class DateSearchVariablesTest extends TestCase public function canBeCreated(): void { $subject = new DateSearchVariables( + [ + ], [ ], new DateDemand(), @@ -30,10 +32,35 @@ class DateSearchVariablesTest extends TestCase ); } + #[Test] + public function returnsInitializeSettings(): void + { + $subject = new DateSearchVariables( + [ + 'someCustomKey' => 'someCustomValue', + ], + [ + ], + new DateDemand(), + $this->createStub(QueryResult::class), + [], + [] + ); + + self::assertSame( + [ + 'someCustomKey' => 'someCustomValue', + ], + $subject->getSettings() + ); + } + #[Test] public function returnsInitializeSearch(): void { $subject = new DateSearchVariables( + [ + ], [ 'executed' => '1', ], @@ -56,6 +83,8 @@ class DateSearchVariablesTest extends TestCase { $demand = new DateDemand(); $subject = new DateSearchVariables( + [ + ], [ ], $demand, @@ -75,6 +104,8 @@ class DateSearchVariablesTest extends TestCase { $regions = $this->createStub(QueryResult::class); $subject = new DateSearchVariables( + [ + ], [ ], new DateDemand(), @@ -93,6 +124,8 @@ class DateSearchVariablesTest extends TestCase public function returnsInitialCategories(): void { $subject = new DateSearchVariables( + [ + ], [ ], new DateDemand(), @@ -115,6 +148,8 @@ class DateSearchVariablesTest extends TestCase public function returnsInitialFeatures(): void { $subject = new DateSearchVariables( + [ + ], [ ], new DateDemand(), @@ -140,6 +175,8 @@ class DateSearchVariablesTest extends TestCase $demand = new DateDemand(); $regions = $this->createStub(QueryResult::class); $subject = new DateSearchVariables( + [ + ], [ 'executed' => '1', ], @@ -177,6 +214,8 @@ class DateSearchVariablesTest extends TestCase $demand = new DateDemand(); $regions = $this->createStub(QueryResult::class); $subject = new DateSearchVariables( + [ + ], [ 'executed' => '1', ], @@ -219,6 +258,8 @@ class DateSearchVariablesTest extends TestCase $demand = new DateDemand(); $regions = $this->createStub(QueryResult::class); $subject = new DateSearchVariables( + [ + ], [ 'executed' => '1', ],