Release 2.0.30 (#4225)
This commit is contained in:
@@ -34,10 +34,16 @@ use InvalidArgumentException;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Validator\ConstraintViolation;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
final class TimesheetService
|
||||
{
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
private array $doNotValidateCodes = [];
|
||||
|
||||
public function __construct(
|
||||
private SystemConfiguration $configuration,
|
||||
private TimesheetRepository $repository,
|
||||
@@ -236,10 +242,25 @@ final class TimesheetService
|
||||
$errors = $this->validator->validate($timesheet, null, $groups);
|
||||
|
||||
if ($errors->count() > 0) {
|
||||
throw new ValidationFailedException($errors, 'Validation Failed');
|
||||
/** @var ConstraintViolation $error */
|
||||
foreach ($errors as $error) {
|
||||
if (\in_array($error->getCode(), $this->doNotValidateCodes, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
throw new ValidationFailedException($errors, 'Validation Failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> $validationCodes
|
||||
*/
|
||||
public function setIgnoreValidationCodes(array $validationCodes): void
|
||||
{
|
||||
$this->doNotValidateCodes = $validationCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure, that the timesheet record has the timezone of the user.
|
||||
*
|
||||
|
||||
@@ -254,7 +254,7 @@ final class TimesheetStatisticService
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DateTime($result, new \DateTimeZone($user->getTimezone()));
|
||||
return new DateTime((string) $result, new \DateTimeZone($user->getTimezone()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user