mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-22 03:36:10 +01:00
Get rid of legacy region property within demand
Only use new way but provide compatibility.
This commit is contained in:
parent
605ad9f9ae
commit
2abc84d1ae
3 changed files with 33 additions and 14 deletions
|
@ -41,12 +41,6 @@ class DateDemand
|
|||
*/
|
||||
protected $categoryCombination = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* Legacy, superceeded by regions which allows multi select / filter.
|
||||
*/
|
||||
protected $region = '';
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
|
@ -109,7 +103,7 @@ class DateDemand
|
|||
$instance->setSearchword($submittedValues['searchword'] ?? '');
|
||||
$instance->setSynonyms($settings['synonyms'] ?? []);
|
||||
|
||||
$instance->setRegion($submittedValues['region'] ?? '');
|
||||
$instance->setRegions(GeneralUtility::intExplode(',', $submittedValues['region'] ?? '', true));
|
||||
if (isset($submittedValues['regions']) && is_array($submittedValues['regions'])) {
|
||||
$instance->setRegions($submittedValues['regions']);
|
||||
}
|
||||
|
@ -231,12 +225,7 @@ class DateDemand
|
|||
|
||||
public function getRegion(): string
|
||||
{
|
||||
return $this->region;
|
||||
}
|
||||
|
||||
public function setRegion(string $region): void
|
||||
{
|
||||
$this->region = $region;
|
||||
return implode(',', $this->regions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Wrm\Events\Domain\Model\Dto;
|
|||
*/
|
||||
|
||||
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
class DateDemandFactory
|
||||
|
@ -59,7 +60,7 @@ class DateDemandFactory
|
|||
}
|
||||
}
|
||||
|
||||
$demand->setRegion((string)$settings['region']);
|
||||
$demand->setRegions(GeneralUtility::intExplode(',', (string)$settings['region'], true));
|
||||
$demand->setCategories((string)$settings['categories']);
|
||||
$categoryCombination = (int)$settings['categoryCombination'] === 1 ? 'or' : 'and';
|
||||
$demand->setCategoryCombination($categoryCombination);
|
||||
|
|
|
@ -126,6 +126,31 @@ class DateDemandTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function regionIsSetByRequest(): void
|
||||
{
|
||||
$result = DateDemand::createFromRequestValues(
|
||||
[
|
||||
'region' => '10',
|
||||
],
|
||||
[
|
||||
]
|
||||
);
|
||||
|
||||
self::assertSame(
|
||||
[
|
||||
10,
|
||||
],
|
||||
$result->getRegions()
|
||||
);
|
||||
self::assertSame(
|
||||
'10',
|
||||
$result->getRegion()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
@ -148,6 +173,10 @@ class DateDemandTest extends TestCase
|
|||
],
|
||||
$result->getRegions()
|
||||
);
|
||||
self::assertSame(
|
||||
'10,20',
|
||||
$result->getRegion()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue