restart via API allows to copy description (#782)

This commit is contained in:
Kevin Papst
2019-05-13 17:32:01 +02:00
committed by GitHub
parent 1f5710eaba
commit bbe1f9beda
28 changed files with 250 additions and 118 deletions

View File

@@ -45,14 +45,6 @@ trait TimesheetControllerTrait
$this->configuration = $configuration;
}
/**
* @return int
*/
protected function getHardLimit()
{
return $this->configuration->getActiveEntriesHardLimit();
}
/**
* @return int
*/
@@ -163,14 +155,17 @@ trait TimesheetControllerTrait
try {
if (null === $entry->getEnd()) {
$this->stopActiveEntries($entry->getUser());
$this->getRepository()->stopActiveEntries(
$entry->getUser(),
$this->configuration->getActiveEntriesHardLimit()
);
}
$entityManager->persist($entry);
$entityManager->flush();
$this->flashSuccess('action.update.success');
} catch (\Exception $ex) {
$this->flashError('timesheet.start.error', ['%reason%' => $ex->getMessage()]);
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
return $this->redirectToRoute($redirectRoute);
@@ -182,17 +177,6 @@ trait TimesheetControllerTrait
]);
}
/**
* @param User $user
* @throws \App\Repository\RepositoryException
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*/
protected function stopActiveEntries(User $user)
{
$this->getRepository()->stopActiveEntries($user, $this->getHardLimit());
}
/**
* @param Timesheet $entry
* @param string $redirectRoute