user-profile - sidebar links and language settings (#369)

This commit is contained in:
Kevin Papst
2018-10-23 23:59:38 +02:00
committed by GitHub
parent 0165658659
commit 6633c550f5
28 changed files with 280 additions and 242 deletions

View File

@@ -89,10 +89,6 @@ class MenuBuilderSubscriber implements EventSubscriberInterface
);
}
$event->addItem(
new MenuItemModel('logout', 'menu.logout', 'fos_user_security_logout', [], 'fas fa-sign-out-alt')
);
$this->activateByRoute(
$event->getRequest()->get('_route'),
$event->getItems()

View File

@@ -9,8 +9,10 @@
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
@@ -21,7 +23,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
*
* @author Oleg Voronkovich <oleg-voronkovich@yandex.ru>
*/
class RedirectToLocaleSubscriber
class RedirectToLocaleSubscriber implements EventSubscriberInterface
{
/**
* @var UrlGeneratorInterface
@@ -70,6 +72,16 @@ class RedirectToLocaleSubscriber
$this->locales = array_unique($this->locales);
}
/**
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => ['onKernelRequest']
];
}
/**
* @param GetResponseEvent $event
*/

View File

@@ -13,11 +13,13 @@ use App\Entity\User;
use App\Entity\UserPreference;
use App\Event\UserPreferenceEvent;
use App\Form\Type\CalendarViewType;
use App\Form\Type\LanguageType;
use App\Form\Type\SkinType;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TimezoneType;
use Symfony\Component\HttpKernel\Event\KernelEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@@ -70,6 +72,16 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
->setValue(0)
->setType(IntegerType::class)
->addConstraint(new Range(['min' => 0])),
/*
(new UserPreference())
->setName('timezone')
->setValue(date_default_timezone_get())
->setType(TimezoneType::class),
*/
(new UserPreference())
->setName('language')
->setValue('en') // TODO fetch from services.yaml
->setType(LanguageType::class),
(new UserPreference())
->setName(UserPreference::SKIN)
@@ -100,13 +112,6 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
->setName('calendar.initial_view')
->setValue(CalendarViewType::DEFAULT_VIEW)
->setType(CalendarViewType::class),
/*
(new UserPreference())
->setName('language')
->setValue('de')
->setType(LanguageType::class),
*/
];
}