Release 2.13 (#4659)

This commit is contained in:
Kevin Papst
2024-03-10 15:35:59 +01:00
committed by GitHub
parent a78e8ed8c4
commit dee90bb15e
79 changed files with 1019 additions and 932 deletions

View File

@@ -18,26 +18,25 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
final class TimesheetOverlappingValidator extends ConstraintValidator
{
public function __construct(private SystemConfiguration $configuration, private TimesheetRepository $repository)
public function __construct(
private readonly SystemConfiguration $configuration,
private readonly TimesheetRepository $repository
)
{
}
/**
* @param TimesheetEntity $timesheet
* @param Constraint $constraint
*/
public function validate(mixed $timesheet, Constraint $constraint): void
public function validate(mixed $value, Constraint $constraint): void
{
if (!($constraint instanceof TimesheetOverlapping)) {
throw new UnexpectedTypeException($constraint, TimesheetOverlapping::class);
}
if (!\is_object($timesheet) || !($timesheet instanceof TimesheetEntity)) {
throw new UnexpectedTypeException($timesheet, TimesheetEntity::class);
if (!\is_object($value) || !($value instanceof TimesheetEntity)) {
throw new UnexpectedTypeException($value, TimesheetEntity::class);
}
$begin = $timesheet->getBegin();
$end = $timesheet->getEnd();
$begin = $value->getBegin();
$end = $value->getEnd();
// this case is handled in TimesheetValidator and should not raise a second validation
if ($begin !== null && $end !== null && $begin > $end) {
@@ -48,7 +47,7 @@ final class TimesheetOverlappingValidator extends ConstraintValidator
return;
}
if (!$this->repository->hasRecordForTime($timesheet)) {
if (!$this->repository->hasRecordForTime($value)) {
return;
}