diff --git a/.env b/.env index f1c566c..95ca49a 100644 --- a/.env +++ b/.env @@ -52,6 +52,9 @@ APP_NAME=YGGtracker APP_LOCALE=en APP_LOCALES=en|cs|eo|fr|ka|de|he|it|lv|pl|pt|ru|es|uk +APP_THEME=default +APP_THEMES=default + APP_TRACKERS=http://[201:23b4:991a:634d:8359:4521:5576:15b7]:2023/announce|http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce|http://[316:c51a:62a3:8b9::5]/announce APP_PAGE_TITLE_LENGTH_MIN=10 diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 8052606..236f109 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -3,6 +3,7 @@ twig: globals: version: '%app.version%' name: '%app.name%' + theme: '%app.theme%' when@test: twig: diff --git a/config/services.yaml b/config/services.yaml index 71fefcb..68124cf 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -8,6 +8,8 @@ parameters: app.name: '%env(APP_NAME)%' app.locale: '%env(APP_LOCALE)%' app.locales: '%env(APP_LOCALES)%' + app.theme: '%env(APP_THEME)%' + app.themes: '%env(APP_THEMES)%' app.trackers: '%env(APP_TRACKERS)%' app.page.title.length.min: '%env(APP_PAGE_TITLE_LENGTH_MIN)%' app.page.title.length.max: '%env(APP_PAGE_TITLE_LENGTH_MAX)%' diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index f0e3975..37075f2 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -134,6 +134,14 @@ class UserController extends AbstractController ); } + // Update theme + if (in_array($request->get('theme'), explode('|', $this->getParameter('app.themes')))) + { + $user->setTheme( + $request->get('theme') + ); + } + // Save changes to DB $userService->save($user); @@ -158,13 +166,15 @@ class UserController extends AbstractController 'status' => $user->isStatus(), 'locale' => $user->getLocale(), 'locales' => $user->getLocales(), + 'theme' => $user->getTheme(), 'added' => $user->getAdded(), 'identicon' => $userService->identicon( $user->getAddress(), 48 ), ], - 'locales' => explode('|', $this->getParameter('app.locales')) + 'locales' => explode('|', $this->getParameter('app.locales')), + 'themes' => explode('|', $this->getParameter('app.themes')) ] ); } diff --git a/src/Entity/User.php b/src/Entity/User.php index fba0937..493e61c 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -35,6 +35,9 @@ class User #[ORM\Column(type: Types::ARRAY)] private array $locales = []; + #[ORM\Column(length: 255)] + private ?string $theme = null; + public function getId(): ?int { return $this->id; @@ -130,4 +133,16 @@ class User return $this; } + + public function getTheme(): ?string + { + return $this->theme; + } + + public function setTheme(string $theme): static + { + $this->theme = $theme; + + return $this; + } } diff --git a/src/Service/UserService.php b/src/Service/UserService.php index ab2981a..e340859 100644 --- a/src/Service/UserService.php +++ b/src/Service/UserService.php @@ -47,6 +47,9 @@ class UserService $user->setLocales( explode('|', $this->parameterBagInterface->get('app.locales')) ); + $user->setTheme( + $this->parameterBagInterface->get('app.theme') + ); $this->save($user); diff --git a/templates/default/layout.html.twig b/templates/default/layout.html.twig index 54900da..f91a1c2 100644 --- a/templates/default/layout.html.twig +++ b/templates/default/layout.html.twig @@ -4,8 +4,8 @@