From 016565865973f7f0bc8e61666623c6e69eccf99c Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Sun, 21 Oct 2018 15:43:16 +0200 Subject: [PATCH] added config for initial calendar view (#363) --- .../ThemeOptionsSubscriber.php | 3 +- .../UserPreferenceSubscriber.php | 6 +++ src/Form/Type/CalendarViewType.php | 52 +++++++++++++++++++ templates/calendar/user.html.twig | 3 +- tests/Controller/ProfileControllerTest.php | 51 ++++++++++++++++++ translations/messages.de.xliff | 17 ++++++ translations/messages.en.xliff | 17 ++++++ var/docs/calendar.md | 11 +++- 8 files changed, 155 insertions(+), 5 deletions(-) create mode 100644 src/Form/Type/CalendarViewType.php diff --git a/src/EventSubscriber/ThemeOptionsSubscriber.php b/src/EventSubscriber/ThemeOptionsSubscriber.php index 7277f213..ff2f4574 100644 --- a/src/EventSubscriber/ThemeOptionsSubscriber.php +++ b/src/EventSubscriber/ThemeOptionsSubscriber.php @@ -18,7 +18,7 @@ use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; /** - * Class ThemeOptionsSubscriber + * Allows dynamic injection of theme related options. */ class ThemeOptionsSubscriber implements EventSubscriberInterface { @@ -33,7 +33,6 @@ class ThemeOptionsSubscriber implements EventSubscriberInterface protected $helper; /** - * ThemeOptionsSubscriber constructor. * @param TokenStorageInterface $storage * @param ContextHelper $helper */ diff --git a/src/EventSubscriber/UserPreferenceSubscriber.php b/src/EventSubscriber/UserPreferenceSubscriber.php index 18e8b5c9..28a30630 100644 --- a/src/EventSubscriber/UserPreferenceSubscriber.php +++ b/src/EventSubscriber/UserPreferenceSubscriber.php @@ -12,6 +12,7 @@ namespace App\EventSubscriber; use App\Entity\User; use App\Entity\UserPreference; use App\Event\UserPreferenceEvent; +use App\Form\Type\CalendarViewType; use App\Form\Type\SkinType; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -95,6 +96,11 @@ class UserPreferenceSubscriber implements EventSubscriberInterface ->setValue(true) ->setType(CheckboxType::class), + (new UserPreference()) + ->setName('calendar.initial_view') + ->setValue(CalendarViewType::DEFAULT_VIEW) + ->setType(CalendarViewType::class), + /* (new UserPreference()) ->setName('language') diff --git a/src/Form/Type/CalendarViewType.php b/src/Form/Type/CalendarViewType.php new file mode 100644 index 00000000..5bb95190 --- /dev/null +++ b/src/Form/Type/CalendarViewType.php @@ -0,0 +1,52 @@ +setDefaults([ + 'required' => true, + 'choices' => $choices, + ]); + } + + /** + * {@inheritdoc} + */ + public function getParent() + { + return ChoiceType::class; + } +} diff --git a/templates/calendar/user.html.twig b/templates/calendar/user.html.twig index 75476e84..97d7422b 100644 --- a/templates/calendar/user.html.twig +++ b/templates/calendar/user.html.twig @@ -24,6 +24,7 @@