redesign user data api

This commit is contained in:
isUnknown 2024-10-28 15:33:52 +01:00
parent f132049948
commit 44361e614d
17 changed files with 80 additions and 52 deletions

View file

@ -1,9 +1,24 @@
<?php
return function ($page) {
return function ($page, $kirby) {
$data = $page->toArray();
$data['template'] = (string) $page->template();
$userData = [
"role" => $kirby->user()->role(),
"uuid" => $kirby->user()->uuid(),
"notifications" => Yaml::decode($kirby->user()->notifications()->value()),
];
if ($kirby->user()->role() == 'client') {
$userData['client'] = [
"name" => $kirby->user()->client()->toPage()->title(),
"uuid" => $kirby->user()->client()->toPage()->uuid()
];
}
return [
'genericData' => $data,
'userData' => $userData
];
};