mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-24 18:16:10 +01:00
Allow integrator to set start or end for date via settings
Respect start and end when creating demand from settings. That way integrator can configure it via TypoScript, or provide an FlexForm. Also the query was adjusted. It now respects a single value and doesn't need start and end. That way upcoming events can be created. Relates: #8581
This commit is contained in:
parent
cf2b571fda
commit
c65ae5023f
2 changed files with 10 additions and 8 deletions
|
@ -167,6 +167,8 @@ class DateController extends ActionController
|
||||||
$demand->setSortBy((string)$this->settings['sortByDate']);
|
$demand->setSortBy((string)$this->settings['sortByDate']);
|
||||||
$demand->setSortOrder((string)$this->settings['sortOrder']);
|
$demand->setSortOrder((string)$this->settings['sortOrder']);
|
||||||
$demand->setHighlight((int)$this->settings['highlight']);
|
$demand->setHighlight((int)$this->settings['highlight']);
|
||||||
|
$demand->setStart((string)$this->settings['start'] ?? '');
|
||||||
|
$demand->setEnd((string)$this->settings['end'] ?? '');
|
||||||
|
|
||||||
if (!empty($this->settings['limit'])) {
|
if (!empty($this->settings['limit'])) {
|
||||||
$demand->setLimit($this->settings['limit']);
|
$demand->setLimit($this->settings['limit']);
|
||||||
|
|
|
@ -80,14 +80,14 @@ class DateRepository extends Repository
|
||||||
$constraints['userCategories'] = $query->in('event.categories.uid', $demand->getUserCategories());
|
$constraints['userCategories'] = $query->in('event.categories.uid', $demand->getUserCategories());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($demand->getStart() !== '' && $demand->getEnd() != '') {
|
if ($demand->getStart() !== '') {
|
||||||
$constraints['daterange'] = $query->logicalAnd(
|
$constraints['starts'] = $query->greaterThanOrEqual('start', $demand->getStart());
|
||||||
[
|
}
|
||||||
$query->greaterThanOrEqual('start', $demand->getStart()),
|
if ($demand->getEnd() != '') {
|
||||||
$query->lessThanOrEqual('end', $demand->getEnd())
|
$constraints['ends'] = $query->lessThanOrEqual('end', $demand->getEnd());
|
||||||
]
|
}
|
||||||
);
|
|
||||||
} else {
|
if ($demand->getStart() === '' && $demand->getEnd() === '') {
|
||||||
$now = new \DateTime('now', new \DateTimeZone('Europe/Berlin'));
|
$now = new \DateTime('now', new \DateTimeZone('Europe/Berlin'));
|
||||||
$constraints['untilnow'] = $query->greaterThanOrEqual('start', $now);
|
$constraints['untilnow'] = $query->greaterThanOrEqual('start', $now);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue