mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-22 04:16:10 +01:00
parent
d682c14252
commit
5721a1d399
5 changed files with 73 additions and 0 deletions
|
@ -51,6 +51,11 @@ class DateDemand
|
||||||
*/
|
*/
|
||||||
protected $locations = [];
|
protected $locations = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int[]
|
||||||
|
*/
|
||||||
|
protected $organizers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
|
@ -213,6 +218,19 @@ class DateDemand
|
||||||
$this->locations = array_map('intval', $locations);
|
$this->locations = array_map('intval', $locations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
public function getOrganizers(): array
|
||||||
|
{
|
||||||
|
return $this->organizers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOrganizers(array $organizers): void
|
||||||
|
{
|
||||||
|
$this->organizers = array_values(array_map('intval', $organizers));
|
||||||
|
}
|
||||||
|
|
||||||
public function getHighlight(): bool
|
public function getHighlight(): bool
|
||||||
{
|
{
|
||||||
return $this->highlight;
|
return $this->highlight;
|
||||||
|
|
|
@ -66,6 +66,9 @@ class DateDemandFactory
|
||||||
if (!empty($settings['locations'])) {
|
if (!empty($settings['locations'])) {
|
||||||
$demand->setLocations(GeneralUtility::intExplode(',', (string)$settings['locations'], true));
|
$demand->setLocations(GeneralUtility::intExplode(',', (string)$settings['locations'], true));
|
||||||
}
|
}
|
||||||
|
if (!empty($settings['organizers'])) {
|
||||||
|
$demand->setOrganizers(GeneralUtility::intExplode(',', (string)$settings['organizers'], true));
|
||||||
|
}
|
||||||
if (!empty($settings['categories'])) {
|
if (!empty($settings['categories'])) {
|
||||||
$demand->setCategories((string)$settings['categories']);
|
$demand->setCategories((string)$settings['categories']);
|
||||||
}
|
}
|
||||||
|
@ -118,6 +121,10 @@ class DateDemandFactory
|
||||||
$instance->setLocations($submittedValues['locations']);
|
$instance->setLocations($submittedValues['locations']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($submittedValues['organizers']) && is_array($submittedValues['organizers'])) {
|
||||||
|
$instance->setOrganizers($submittedValues['organizers']);
|
||||||
|
}
|
||||||
|
|
||||||
$instance->setRegions(GeneralUtility::intExplode(',', $submittedValues['region'] ?? '', true));
|
$instance->setRegions(GeneralUtility::intExplode(',', $submittedValues['region'] ?? '', true));
|
||||||
if (isset($submittedValues['regions']) && is_array($submittedValues['regions'])) {
|
if (isset($submittedValues['regions']) && is_array($submittedValues['regions'])) {
|
||||||
$instance->setRegions($submittedValues['regions']);
|
$instance->setRegions($submittedValues['regions']);
|
||||||
|
|
|
@ -61,6 +61,10 @@ class DateRepository extends Repository
|
||||||
$constraints['locations'] = $query->in('event.location', $demand->getLocations());
|
$constraints['locations'] = $query->in('event.location', $demand->getLocations());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($demand->getOrganizers() !== []) {
|
||||||
|
$constraints['organizer'] = $query->in('event.organizer', $demand->getOrganizers());
|
||||||
|
}
|
||||||
|
|
||||||
if ($demand->getRegion() !== '') {
|
if ($demand->getRegion() !== '') {
|
||||||
$constraints['region'] = $query->equals('event.region', $demand->getRegion());
|
$constraints['region'] = $query->equals('event.region', $demand->getRegion());
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,12 @@ Features
|
||||||
|
|
||||||
* Add PHP 8.2 support.
|
* Add PHP 8.2 support.
|
||||||
|
|
||||||
|
* Added option to filter dates by organizers.
|
||||||
|
The new setting works the same way as existing ``locations``.
|
||||||
|
Add a comma separated list of UIDs.
|
||||||
|
This can be used via FlexForms or TypoScript.
|
||||||
|
Can also be used as filter from request, where an array of UIDs is expected.
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -473,4 +473,42 @@ class DateDemandFactoryTest extends TestCase
|
||||||
yield '0 as string' => ['highlight' => '0'];
|
yield '0 as string' => ['highlight' => '0'];
|
||||||
yield 'empty string' => ['highlight' => ''];
|
yield 'empty string' => ['highlight' => ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function returnsOrganizersFromSettings(): void
|
||||||
|
{
|
||||||
|
$typoScriptService = $this->createStub(TypoScriptService::class);
|
||||||
|
|
||||||
|
$subject = new DateDemandFactory(
|
||||||
|
$typoScriptService
|
||||||
|
);
|
||||||
|
$result = $subject->fromSettings([
|
||||||
|
'organizers' => '10, ,0, 2,',
|
||||||
|
]);
|
||||||
|
|
||||||
|
self::assertSame([10, 0, 2], $result->getOrganizers());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function returnsOrganizersFromRequest(): void
|
||||||
|
{
|
||||||
|
$typoScriptService = $this->createStub(TypoScriptService::class);
|
||||||
|
|
||||||
|
$subject = new DateDemandFactory(
|
||||||
|
$typoScriptService
|
||||||
|
);
|
||||||
|
$result = $subject->createFromRequestValues(
|
||||||
|
[
|
||||||
|
'organizers' => [10, 0, 2],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
self::assertSame([10, 0, 2], $result->getOrganizers());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue