designtopack/public/site/controllers/site.php

27 lines
678 B
PHP
Raw Normal View History

2024-07-11 12:42:29 +02:00
<?php
2024-10-29 11:20:31 +01:00
return function ($page, $kirby, $site) {
if (!$kirby->user()) {
go($site->panel()->url());
}
2024-07-11 12:42:29 +02:00
$data = $page->toArray();
$data['template'] = (string) $page->template();
2024-10-28 15:33:52 +01:00
$userData = [
"role" => (string) $kirby->user()->role(),
"uuid" => (string) $kirby->user()->uuid(),
2024-10-28 15:33:52 +01:00
"notifications" => Yaml::decode($kirby->user()->notifications()->value()),
];
if ($kirby->user()->role() == 'client') {
$userData['client'] = [
"name" => (string) $kirby->user()->client()->toPage()->title(),
"uuid" => (string) $kirby->user()->client()->toPage()->uuid()
2024-10-28 15:33:52 +01:00
];
}
2024-07-11 12:42:29 +02:00
return [
'genericData' => $data,
2024-10-28 15:33:52 +01:00
'userData' => $userData
2024-07-11 12:42:29 +02:00
];
};