Release 2.36.0 (#5514)
This commit is contained in:
@@ -63,24 +63,6 @@ final class ValidationFailedExceptionErrorHandler implements SubscribingHandlerI
|
||||
}
|
||||
|
||||
public function serializeValidationExceptionToJson(JsonSerializationVisitor $visitor, ValidationFailedException $exception, array $type, Context $context)
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
/** @var ConstraintViolationInterface $error */
|
||||
foreach (iterator_to_array($exception->getViolations()) as $error) {
|
||||
$errors[$error->getPropertyPath()]['errors'][] = $this->getErrorMessage($error);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => '400',
|
||||
'message' => $this->translator->trans($exception->getMessage(), [], 'validators'),
|
||||
'errors' => [
|
||||
'children' => $errors
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getErrorMessage(ConstraintViolationInterface $error): string
|
||||
{
|
||||
$locale = \Locale::getDefault();
|
||||
/** @var User $user */
|
||||
@@ -90,6 +72,24 @@ final class ValidationFailedExceptionErrorHandler implements SubscribingHandlerI
|
||||
$locale = $user->getLanguage();
|
||||
}
|
||||
|
||||
$errors = [];
|
||||
|
||||
/** @var ConstraintViolationInterface $error */
|
||||
foreach (iterator_to_array($exception->getViolations()) as $error) {
|
||||
$errors[$error->getPropertyPath()]['errors'][] = $this->getErrorMessage($error, $locale);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => '400',
|
||||
'message' => $this->translator->trans($exception->getMessage(), [], 'validators', $locale),
|
||||
'errors' => [
|
||||
'children' => $errors
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getErrorMessage(ConstraintViolationInterface $error, string $locale): string
|
||||
{
|
||||
if (null !== $error->getPlural()) {
|
||||
return $this->translator->trans($error->getMessageTemplate(), ['%count%' => $error->getPlural()] + $error->getParameters(), 'validators', $locale);
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ final class TimesheetController extends BaseApiController
|
||||
|
||||
if ($form->isValid()) {
|
||||
try {
|
||||
$this->service->saveNewTimesheet($timesheet);
|
||||
$this->service->saveTimesheet($timesheet);
|
||||
|
||||
$view = new View($timesheet, 200);
|
||||
|
||||
@@ -372,7 +372,7 @@ final class TimesheetController extends BaseApiController
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
$this->service->updateTimesheet($timesheet);
|
||||
$this->service->saveTimesheet($timesheet);
|
||||
|
||||
$view = new View($timesheet, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
@@ -547,7 +547,7 @@ final class TimesheetController extends BaseApiController
|
||||
$copyTimesheet = clone $timesheet;
|
||||
|
||||
$this->dispatcher->dispatch(new TimesheetDuplicatePreEvent($copyTimesheet, $timesheet));
|
||||
$this->service->saveNewTimesheet($copyTimesheet);
|
||||
$this->service->saveTimesheet($copyTimesheet);
|
||||
$this->dispatcher->dispatch(new TimesheetDuplicatePostEvent($copyTimesheet, $timesheet));
|
||||
|
||||
$view = new View($copyTimesheet, 200);
|
||||
@@ -571,7 +571,7 @@ final class TimesheetController extends BaseApiController
|
||||
|
||||
$timesheet->setExported(!$timesheet->isExported());
|
||||
|
||||
$this->service->updateTimesheet($timesheet);
|
||||
$this->service->saveTimesheet($timesheet);
|
||||
|
||||
$view = new View($timesheet, 200);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
@@ -601,7 +601,7 @@ final class TimesheetController extends BaseApiController
|
||||
|
||||
$meta->setValue($paramFetcher->get('value'));
|
||||
|
||||
$this->service->updateTimesheet($timesheet);
|
||||
$this->service->saveTimesheet($timesheet);
|
||||
|
||||
$view = new View($timesheet, 200);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
Reference in New Issue
Block a user