performance improvements (#2329)

* remove work from constructor
* refactor twig extensions
* upgrade theme
* replace sub-request with direct template rendering
This commit is contained in:
Kevin Papst
2021-02-20 23:52:01 +01:00
committed by GitHub
parent 9eb25c412e
commit 607d09aefb
40 changed files with 992 additions and 1092 deletions

View File

@@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class UserEnvironmentSubscriber implements EventSubscriberInterface
final class UserEnvironmentSubscriber implements EventSubscriberInterface
{
/**
* @var TokenStorageInterface
@@ -40,20 +40,22 @@ class UserEnvironmentSubscriber implements EventSubscriberInterface
];
}
public function prepareEnvironment(RequestEvent $event)
public function prepareEnvironment(RequestEvent $event): void
{
// ignore sub-requests
if (!$event->isMasterRequest()) {
return;
}
if (null === $this->storage->getToken()) {
// the locale depends on the request, not on the user configuration
\Locale::setDefault($event->getRequest()->getLocale());
// ignore events like the toolbar where we do not have a token
if (null === ($token = $this->storage->getToken())) {
return;
}
$user = $this->storage->getToken()->getUser();
// the locale depends on the request, not on the user configuration
\Locale::setDefault($event->getRequest()->getLocale());
$user = $token->getUser();
if ($user instanceof User) {
date_default_timezone_set($user->getTimezone());