Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -16,32 +16,23 @@ use App\Model\QuickEntryWeek;
use App\Repository\Query\TimesheetQuery;
use App\Repository\TimesheetRepository;
use App\Timesheet\TimesheetService;
use App\Utils\PageSetup;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
/**
* Controller used to enter times in weekly form.
*
* @Route(path="/quick_entry")
* @Security("is_granted('quick-entry')")
*/
class QuickEntryController extends AbstractController
#[Route(path: '/quick_entry')]
#[Security("is_granted('quick-entry')")]
final class QuickEntryController extends AbstractController
{
private $configuration;
private $timesheetService;
private $repository;
public function __construct(SystemConfiguration $configuration, TimesheetService $timesheetService, TimesheetRepository $repository)
public function __construct(private SystemConfiguration $configuration, private TimesheetService $timesheetService, private TimesheetRepository $repository)
{
$this->configuration = $configuration;
$this->timesheetService = $timesheetService;
$this->repository = $repository;
}
/**
* @Route(path="/{begin}", name="quick_entry", methods={"GET", "POST"})
*/
#[Route(path: '/{begin}', name: 'quick_entry', methods: ['GET', 'POST'])]
public function quickEntry(Request $request, ?string $begin = null)
{
$factory = $this->getDateTimeFactory();
@@ -67,7 +58,7 @@ class QuickEntryController extends AbstractController
$query->setBegin($startWeek);
$query->setEnd($endWeek);
$query->setName('quickEntryForm');
$query->setUser($this->getUser());
$query->setUser($user);
$result = $this->repository->getTimesheetResult($query);
@@ -104,7 +95,7 @@ class QuickEntryController extends AbstractController
$startFrom = clone $startWeek;
$startFrom->modify(sprintf('-%s weeks', $takeOverWeeks));
}
$timesheets = $this->repository->getRecentActivities($this->getUser(), $startFrom, $amount);
$timesheets = $this->repository->getRecentActivities($user, $startFrom, $amount);
foreach ($timesheets as $timesheet) {
$id = $timesheet->getProject()->getId() . '_' . $timesheet->getActivity()->getId();
if (\array_key_exists($id, $rows)) {
@@ -112,7 +103,7 @@ class QuickEntryController extends AbstractController
}
// there is an edge case possible with a project that starts and ends between the start and end date
// user could still select it from the dropdown, but it is better to hide a row than displaying already ended projects
if (!$timesheet->getProject()->isVisibleAtDate($startWeek) && !$timesheet->getProject()->isVisibleAtDate($endWeek)) {
if ($timesheet->getProject() !== null && (!$timesheet->getProject()->isVisibleAtDate($startWeek) && !$timesheet->getProject()->isVisibleAtDate($endWeek))) {
continue;
}
$rows[$id] = [
@@ -225,12 +216,15 @@ class QuickEntryController extends AbstractController
return $this->redirectToRoute('quick_entry', ['begin' => $begin->format('Y-m-d')]);
}
} catch (\Exception $ex) {
$this->flashError('action.update.error');
$this->logException($ex);
$this->flashUpdateException($ex);
}
}
$page = new PageSetup('quick_entry.title');
$page->setHelp('weekly-times.html');
return $this->render('quick-entry/index.html.twig', [
'page_setup' => $page,
'days' => $week,
'form' => $form->createView(),
]);