mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 09:35:28 +00:00
implement theme settings #17
This commit is contained in:
parent
0ab282e1c4
commit
5a940541ee
8 changed files with 55 additions and 3 deletions
|
|
@ -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'))
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ class UserService
|
|||
$user->setLocales(
|
||||
explode('|', $this->parameterBagInterface->get('app.locales'))
|
||||
);
|
||||
$user->setTheme(
|
||||
$this->parameterBagInterface->get('app.theme')
|
||||
);
|
||||
|
||||
$this->save($user);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue