fix timezone problems in timesheet forms (#555)

This commit is contained in:
Kevin Papst
2019-02-13 21:37:54 +01:00
committed by GitHub
parent 2c6f57c7ce
commit ef33233624
23 changed files with 461 additions and 61 deletions

View File

@@ -46,7 +46,7 @@ class TimezoneSubscriber implements EventSubscriberInterface
*/
public function setTimezone(GetResponseEvent $event)
{
if (null === $this->storage->getToken()) {
if (!$this->canHandleEvent()) {
return;
}
@@ -55,4 +55,24 @@ class TimezoneSubscriber implements EventSubscriberInterface
$timezone = $user->getPreferenceValue('timezone', date_default_timezone_get());
date_default_timezone_set($timezone);
}
/**
* @return bool
*/
protected function canHandleEvent(): bool
{
if (null === $this->storage->getToken()) {
return false;
}
/* @var $user User */
$user = $this->storage->getToken()->getUser();
if (null === $user) {
return false;
}
return ($user instanceof User);
}
}