diff --git a/src/Controller/TimesheetAbstractController.php b/src/Controller/TimesheetAbstractController.php index 4962d66d..e05b14f1 100644 --- a/src/Controller/TimesheetAbstractController.php +++ b/src/Controller/TimesheetAbstractController.php @@ -215,7 +215,7 @@ abstract class TimesheetAbstractController extends AbstractController { $copyTimesheet = clone $timesheet; - $form = $this->getDuplicateForm($timesheet); + $form = $this->getDuplicateForm($copyTimesheet, $timesheet); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -605,7 +605,7 @@ abstract class TimesheetAbstractController extends AbstractController return $query; } - abstract protected function getDuplicateForm(Timesheet $entry): FormInterface; + abstract protected function getDuplicateForm(Timesheet $entry, Timesheet $original): FormInterface; abstract protected function getCreateForm(Timesheet $entry): FormInterface; } diff --git a/src/Controller/TimesheetController.php b/src/Controller/TimesheetController.php index 7ca9fbe2..df14b2cc 100644 --- a/src/Controller/TimesheetController.php +++ b/src/Controller/TimesheetController.php @@ -100,8 +100,8 @@ class TimesheetController extends TimesheetAbstractController return $this->generateCreateForm($entry, TimesheetEditForm::class, $this->generateUrl('timesheet_create')); } - protected function getDuplicateForm(Timesheet $entry): FormInterface + protected function getDuplicateForm(Timesheet $entry, Timesheet $original): FormInterface { - return $this->generateCreateForm($entry, TimesheetEditForm::class, $this->generateUrl('timesheet_duplicate', ['id' => $entry->getId()])); + return $this->generateCreateForm($entry, TimesheetEditForm::class, $this->generateUrl('timesheet_duplicate', ['id' => $original->getId()])); } } diff --git a/src/Controller/TimesheetTeamController.php b/src/Controller/TimesheetTeamController.php index ddf18471..9cd14726 100644 --- a/src/Controller/TimesheetTeamController.php +++ b/src/Controller/TimesheetTeamController.php @@ -195,9 +195,9 @@ class TimesheetTeamController extends TimesheetAbstractController return $this->generateCreateForm($entry, TimesheetAdminEditForm::class, $this->generateUrl('admin_timesheet_create')); } - protected function getDuplicateForm(Timesheet $entry): FormInterface + protected function getDuplicateForm(Timesheet $entry, Timesheet $original): FormInterface { - return $this->generateCreateForm($entry, TimesheetAdminEditForm::class, $this->generateUrl('admin_timesheet_duplicate', ['id' => $entry->getId()])); + return $this->generateCreateForm($entry, TimesheetAdminEditForm::class, $this->generateUrl('admin_timesheet_duplicate', ['id' => $original->getId()])); } protected function getPermissionEditExport(): string diff --git a/src/Timesheet/TimesheetService.php b/src/Timesheet/TimesheetService.php index 5e05083e..dfaf039e 100644 --- a/src/Timesheet/TimesheetService.php +++ b/src/Timesheet/TimesheetService.php @@ -155,6 +155,7 @@ final class TimesheetService $this->repository->save($timesheet); $this->dispatcher->dispatch(new TimesheetCreatePostEvent($timesheet)); + // TODO really stop always or only if $timesheet->getEnd() === null try { $this->stopActiveEntries($timesheet); } catch (ValidationFailedException $vex) {