Skip to content

Commit

Permalink
Fix #813 - Add new event to modify the date time frame constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Jan 24, 2025
1 parent 7ac7c01 commit 836862c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 38 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/.php_cs export-ignore
/.php_cs.cache export-ignore
Expand Down
34 changes: 0 additions & 34 deletions .scrutinizer.yml

This file was deleted.

12 changes: 11 additions & 1 deletion Classes/Domain/Repository/IndexRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use HDNET\Calendarize\Event\IndexRepositoryDefaultConstraintEvent;
use HDNET\Calendarize\Event\IndexRepositoryFindBySearchEvent;
use HDNET\Calendarize\Event\IndexRepositoryTimeSlotEvent;
use HDNET\Calendarize\Event\ModifyDateTimeFrameConstraintEvent;
use HDNET\Calendarize\Utility\ConfigurationUtility;
use HDNET\Calendarize\Utility\DateTimeUtility;
use HDNET\Calendarize\Utility\ExtensionConfigurationUtility;
Expand Down Expand Up @@ -633,8 +634,17 @@ protected function addDateTimeFrameConstraint(
);
}
}

/** @var ModifyDateTimeFrameConstraintEvent $event */
$event = $this->eventDispatcher->dispatch(new ModifyDateTimeFrameConstraintEvent(
$query,
$start,
$end,
$respectTime,
$dateConstraints
));

$constraints[] = $query->logicalAnd(...$dateConstraints);
$constraints[] = $query->logicalAnd(...$event->getDateConstraints());
}

/**
Expand Down
51 changes: 51 additions & 0 deletions Classes/Event/ModifyDateTimeFrameConstraintEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace HDNET\Calendarize\Event;

use TYPO3\CMS\Extbase\Mvc\Controller\Arguments;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;

final class ModifyDateTimeFrameConstraintEvent
{
public function __construct(
protected QueryInterface $query,
protected ?\DateTimeInterface $start,
protected ?\DateTimeInterface $end,
protected bool $respectTime,
protected array $dateConstraints,
)
{
}

public function getQuery(): QueryInterface
{
return $this->query;
}

public function getStart(): ?\DateTimeInterface
{
return $this->start;
}

public function getEnd(): ?\DateTimeInterface
{
return $this->end;
}

public function isRespectTime(): bool
{
return $this->respectTime;
}

public function getDateConstraints(): array
{
return $this->dateConstraints;
}

public function setDateConstraints(array $dateConstraints): void
{
$this->dateConstraints = $dateConstraints;
}

}
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
"typo3/cms-workspaces": "^12.4||^13.4",
"friendsofphp/php-cs-fixer": "^3.0",
"phpmd/phpmd": "^2.4",
"scrutinizer/ocular": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan": "^2.0",
"qossmic/deptrac-shim": "^0.24||^1.0"
},
"config": {
Expand Down

0 comments on commit 836862c

Please sign in to comment.