implement theme settings #17

This commit is contained in:
ghost 2023-10-09 16:33:07 +03:00
parent 0ab282e1c4
commit 5a940541ee
8 changed files with 55 additions and 3 deletions

View file

@ -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'))
]
);
}

View file

@ -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;
}
}

View file

@ -47,6 +47,9 @@ class UserService
$user->setLocales(
explode('|', $this->parameterBagInterface->get('app.locales'))
);
$user->setTheme(
$this->parameterBagInterface->get('app.theme')
);
$this->save($user);