Upgrade to 3.3.0

This commit is contained in:
Bastian Allgeier
2019-11-05 09:35:58 +01:00
parent 447a9dd266
commit a431716732
186 changed files with 3068 additions and 1458 deletions

View File

@@ -1,44 +1,13 @@
<?php
use Kirby\Cms\UserPicker;
return [
'methods' => [
'userpicker' => function (array $params = []) {
$params['model'] = $this->model();
// fetch the parent model
$model = $this->model();
// find the right default query
if (empty($params['query']) === false) {
$query = $params['query'];
} elseif (is_a($model, 'Kirby\Cms\User') === true) {
$query = 'user.siblings';
} else {
$query = 'kirby.users';
}
// fetch all users for the picker
$users = $model->query($query, 'Kirby\Cms\Users');
$data = [];
if (!$users) {
return [];
}
// prepare the response for each user
foreach ($users->sortBy('username', 'asc') as $index => $user) {
if (empty($params['map']) === false) {
$data[] = $params['map']($user);
} else {
$data[] = $user->panelPickerData([
'image' => $params['image'] ?? [],
'info' => $params['info'] ?? false,
'model' => $model,
'text' => $params['text'] ?? '{{ user.username }}',
]);
}
}
return $data;
return (new UserPicker($params))->toArray();
}
]
];