Release 2.54 (#5896)

This commit is contained in:
Kevin Papst
2026-04-13 21:22:06 +02:00
committed by GitHub
parent 16703081cd
commit bad92d7215
30 changed files with 232 additions and 91 deletions

View File

@@ -29,20 +29,30 @@ final class ContractExtensions extends AbstractExtension
return [
/* @var array{user: User, date: \DateTimeInterface} $values */
new TwigTest('work_day', function (array $values): bool {
$user = $values['user'];
if ($user->getId() === null) {
return false;
// TODO remove me in 3.0, deprecate with 2.55
if (!\array_key_exists('user', $values) || !\array_key_exists('date', $values)) {
throw new \Exception('Missing variable "user" or "date" to check for "is work_day');
}
$id = 'user_' . $user->getId();
if (!\array_key_exists($id, $this->calculators)) {
$this->calculators[$id] = $this->workingTimeService->getContractMode($user)->getCalculator($user);
}
$date = $values['date'];
return $this->calculators[$id]->isWorkDay($date);
return $this->isWorkingDay($values['date'], $values['user']);
}),
new TwigTest('working_day', function (\DateTimeInterface $date, User $user): bool {
return $this->isWorkingDay($date, $user);
}),
];
}
private function isWorkingDay(\DateTimeInterface $date, User $user): bool
{
if ($user->getId() === null) {
return false;
}
$id = 'user_' . $user->getId();
if (!\array_key_exists($id, $this->calculators)) {
$this->calculators[$id] = $this->workingTimeService->getContractMode($user)->getCalculator($user);
}
return $this->calculators[$id]->isWorkDay($date);
}
}