cleanup global context (#1943)
This commit is contained in:
@@ -13,7 +13,6 @@ use App\Calendar\Google;
|
||||
use App\Calendar\Source;
|
||||
use App\Configuration\CalendarConfiguration;
|
||||
use App\Timesheet\TrackingModeService;
|
||||
use App\Timesheet\UserDateTimeFactory;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
@@ -28,14 +27,14 @@ class CalendarController extends AbstractController
|
||||
/**
|
||||
* @Route(path="/", name="calendar", methods={"GET"})
|
||||
*/
|
||||
public function userCalendar(CalendarConfiguration $configuration, UserDateTimeFactory $dateTime, TrackingModeService $service)
|
||||
public function userCalendar(CalendarConfiguration $configuration, TrackingModeService $service)
|
||||
{
|
||||
$mode = $service->getActiveMode();
|
||||
|
||||
return $this->render('calendar/user.html.twig', [
|
||||
'config' => $configuration,
|
||||
'google' => $this->getGoogleSources($configuration),
|
||||
'now' => $dateTime->createDateTime(),
|
||||
'now' => $this->getDateTimeFactory()->createDateTime(),
|
||||
'is_punch_mode' => !$mode->canEditDuration() && !$mode->canEditBegin() && !$mode->canEditEnd()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ use App\Repository\InvoiceRepository;
|
||||
use App\Repository\InvoiceTemplateRepository;
|
||||
use App\Repository\Query\BaseQuery;
|
||||
use App\Repository\Query\InvoiceQuery;
|
||||
use App\Timesheet\UserDateTimeFactory;
|
||||
use Exception;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -49,10 +48,6 @@ final class InvoiceController extends AbstractController
|
||||
* @var InvoiceTemplateRepository
|
||||
*/
|
||||
private $templateRepository;
|
||||
/**
|
||||
* @var UserDateTimeFactory
|
||||
*/
|
||||
private $dateTimeFactory;
|
||||
/**
|
||||
* @var InvoiceRepository
|
||||
*/
|
||||
@@ -62,12 +57,11 @@ final class InvoiceController extends AbstractController
|
||||
*/
|
||||
private $dispatcher;
|
||||
|
||||
public function __construct(ServiceInvoice $service, InvoiceTemplateRepository $templateRepository, InvoiceRepository $invoiceRepository, UserDateTimeFactory $dateTimeFactory, EventDispatcherInterface $dispatcher)
|
||||
public function __construct(ServiceInvoice $service, InvoiceTemplateRepository $templateRepository, InvoiceRepository $invoiceRepository, EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
$this->service = $service;
|
||||
$this->templateRepository = $templateRepository;
|
||||
$this->invoiceRepository = $invoiceRepository;
|
||||
$this->dateTimeFactory = $dateTimeFactory;
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
@@ -139,8 +133,9 @@ final class InvoiceController extends AbstractController
|
||||
|
||||
protected function getDefaultQuery(): InvoiceQuery
|
||||
{
|
||||
$begin = $this->dateTimeFactory->createDateTime('first day of this month');
|
||||
$end = $this->dateTimeFactory->createDateTime('last day of this month');
|
||||
$factory = $this->getDateTimeFactory();
|
||||
$begin = $factory->getStartOfMonth();
|
||||
$end = $factory->getEndOfMonth();
|
||||
|
||||
$query = new InvoiceQuery();
|
||||
$query->setOrder(InvoiceQuery::ORDER_ASC);
|
||||
|
||||
@@ -29,7 +29,6 @@ use App\Repository\TimesheetRepository;
|
||||
use App\Timesheet\TimesheetService;
|
||||
use App\Timesheet\TrackingMode\TrackingModeInterface;
|
||||
use App\Timesheet\TrackingModeService;
|
||||
use App\Timesheet\UserDateTimeFactory;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -38,10 +37,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
abstract class TimesheetAbstractController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @var UserDateTimeFactory
|
||||
*/
|
||||
protected $dateTime;
|
||||
/**
|
||||
* @var TimesheetRepository
|
||||
*/
|
||||
@@ -64,14 +59,12 @@ abstract class TimesheetAbstractController extends AbstractController
|
||||
protected $service;
|
||||
|
||||
public function __construct(
|
||||
UserDateTimeFactory $dateTime,
|
||||
TimesheetRepository $repository,
|
||||
TrackingModeService $trackingModeService,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
ServiceExport $exportService,
|
||||
TimesheetService $timesheetService
|
||||
) {
|
||||
$this->dateTime = $dateTime;
|
||||
$this->repository = $repository;
|
||||
$this->trackingModeService = $trackingModeService;
|
||||
$this->dispatcher = $dispatcher;
|
||||
@@ -238,16 +231,18 @@ abstract class TimesheetAbstractController extends AbstractController
|
||||
$form->setData($query);
|
||||
$form->submit($request->query->all(), false);
|
||||
|
||||
$factory = $this->getDateTimeFactory();
|
||||
|
||||
// by default the current month is exported, but it can be overwritten
|
||||
// this should not be removed, otherwise we would export EVERY available record in the admin section
|
||||
// as the default toolbar query does neither limit the user nor the date-range!
|
||||
if (null === $query->getBegin()) {
|
||||
$query->setBegin($this->dateTime->createDateTime('first day of this month'));
|
||||
$query->setBegin($factory->getStartOfMonth());
|
||||
}
|
||||
$query->getBegin()->setTime(0, 0, 0);
|
||||
|
||||
if (null === $query->getEnd()) {
|
||||
$query->setEnd($this->dateTime->createDateTime('last day of this month'));
|
||||
$query->setEnd($factory->getEndOfMonth());
|
||||
}
|
||||
$query->getEnd()->setTime(23, 59, 59);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user