[PLUGINS][Oomox] getEntity added.

[CORE][Cache] exists added.
This commit is contained in:
2021-11-26 17:11:28 +00:00
committed by Diogo Peralta Cordeiro
parent 7b9d388a44
commit 7145dba8af
3 changed files with 26 additions and 6 deletions

View File

@@ -140,14 +140,17 @@ class Oomox
return ['_template' => 'oomox/oomoxSettings.html.twig', 'oomox' => $form->createView()];
}
/**
* @throws ClientException
* @throws \App\Util\Exception\NoLoggedInUser
* @throws ServerException
*/
public function oomoxCSS() {
$user = Common::ensureLoggedIn();
$actor_id = $user->getId();
try {
$oomox_table = Cache::get("oomox-css-{$actor_id}", fn() => DB::findOneBy('oomox', ['actor_id' => $actor_id]));
} catch (NotFoundException $e) {
throw new ClientException(_m('No custom colours defined.'),404, $e);
$oomox_table = \Plugin\Oomox\Oomox::getEntity($user);
if (is_null($oomox_table)) {
throw new ClientException(_m('No custom colors defined', 404));
}
$content = Formatting::twigRenderFile('/oomox/root_override.css.twig', ['oomox' => $oomox_table]);