Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)
This commit is contained in:
@@ -14,6 +14,7 @@ use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\User;
|
||||
use App\Form\CalendarForm;
|
||||
use App\Timesheet\TrackingModeService;
|
||||
use App\Utils\PageSetup;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -21,27 +22,17 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
/**
|
||||
* Controller used to display calendars.
|
||||
*
|
||||
* @Route(path="/calendar")
|
||||
* @Security("is_granted('IS_AUTHENTICATED_REMEMBERED')")
|
||||
*/
|
||||
class CalendarController extends AbstractController
|
||||
#[Route(path: '/calendar')]
|
||||
#[Security("is_granted('IS_AUTHENTICATED_REMEMBERED')")]
|
||||
final class CalendarController extends AbstractController
|
||||
{
|
||||
private $calendarService;
|
||||
private $configuration;
|
||||
private $service;
|
||||
|
||||
public function __construct(CalendarService $calendarService, SystemConfiguration $configuration, TrackingModeService $service)
|
||||
public function __construct(private CalendarService $calendarService, private SystemConfiguration $configuration, private TrackingModeService $service)
|
||||
{
|
||||
$this->calendarService = $calendarService;
|
||||
$this->configuration = $configuration;
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/", name="calendar", methods={"GET"})
|
||||
* @Route(path="/{profile}", name="calendar_user", methods={"GET"})
|
||||
*/
|
||||
#[Route(path: '/', name: 'calendar', methods: ['GET'])]
|
||||
#[Route(path: '/{profile}', name: 'calendar_user', methods: ['GET'])]
|
||||
public function userCalendar(Request $request): Response
|
||||
{
|
||||
$form = null;
|
||||
@@ -72,7 +63,13 @@ class CalendarController extends AbstractController
|
||||
|
||||
$mode = $this->service->getActiveMode();
|
||||
$factory = $this->getDateTimeFactory();
|
||||
$defaultStart = $factory->createDateTime($this->configuration->getTimesheetDefaultBeginTime());
|
||||
|
||||
// if now is default time, we do not pass it on, so it can be re-calculated for each new entry
|
||||
$defaultStart = null;
|
||||
if ($this->configuration->getTimesheetDefaultBeginTime() !== 'now') {
|
||||
$defaultStart = $factory->createDateTime($this->configuration->getTimesheetDefaultBeginTime());
|
||||
$defaultStart = $defaultStart->format('h:i:s');
|
||||
}
|
||||
|
||||
$config = $this->calendarService->getConfiguration();
|
||||
|
||||
@@ -87,14 +84,18 @@ class CalendarController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
$page = new PageSetup('calendar');
|
||||
$page->setHelp('calendar.html');
|
||||
|
||||
return $this->render('calendar/user.html.twig', [
|
||||
'page_setup' => $page,
|
||||
'form' => $form,
|
||||
'user' => $profile,
|
||||
'config' => $config,
|
||||
'dragAndDrop' => $dragAndDrop,
|
||||
'google' => $this->calendarService->getGoogleSources($profile),
|
||||
'now' => $factory->createDateTime(),
|
||||
'defaultStartTime' => $defaultStart->format('h:i:s'),
|
||||
'defaultStartTime' => $defaultStart,
|
||||
'is_punch_mode' => $isPunchMode,
|
||||
'can_edit_begin' => $mode->canEditBegin(),
|
||||
'can_edit_end' => $mode->canEditBegin(),
|
||||
|
||||
Reference in New Issue
Block a user