adasd
This commit is contained in:
@@ -20,22 +20,11 @@ final class DesktopState
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, string>>
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function defaultWidgets(): array
|
||||
public static function defaultWidgetIds(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'widget_id' => 'public-home',
|
||||
'title' => 'Public Home',
|
||||
'content' => 'Oeffentliches Dashboard als Startzustand fuer nicht eingeloggte Nutzer.',
|
||||
],
|
||||
[
|
||||
'widget_id' => 'personal-links',
|
||||
'title' => 'Persoenliche Links',
|
||||
'content' => 'Platzhalter fuer spaetere user-spezifische Linklisten und Dashboards.',
|
||||
],
|
||||
];
|
||||
return ['public-home', 'personal-links', 'system-status'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,4 +38,28 @@ final class DesktopState
|
||||
['id' => 'account', 'label' => 'Gast'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, string>>
|
||||
*/
|
||||
public static function quickActions(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'action_id' => 'open-public-dashboard',
|
||||
'label' => 'Public Dashboard',
|
||||
'description' => 'Oeffnet die oeffentliche Startansicht als Fenster.',
|
||||
],
|
||||
[
|
||||
'action_id' => 'toggle-all-widgets',
|
||||
'label' => 'Widgets umschalten',
|
||||
'description' => 'Blendet alle registrierten Widgets ein oder aus.',
|
||||
],
|
||||
[
|
||||
'action_id' => 'cycle-skin',
|
||||
'label' => 'Skin wechseln',
|
||||
'description' => 'Wechselt zyklisch zwischen Windows, Apple und Linux.',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
40
src/Desktop/WidgetRegistry.php
Normal file
40
src/Desktop/WidgetRegistry.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Desktop;
|
||||
|
||||
final class WidgetRegistry
|
||||
{
|
||||
/** @var array<int, array<string, mixed>> */
|
||||
private array $widgets;
|
||||
|
||||
public function __construct(string $configPath)
|
||||
{
|
||||
/** @var array<int, array<string, mixed>> $widgets */
|
||||
$widgets = require $configPath;
|
||||
$this->widgets = $widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
return $this->widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $widgetIds
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function active(array $widgetIds): array
|
||||
{
|
||||
$lookup = array_fill_keys($widgetIds, true);
|
||||
|
||||
return array_values(array_filter(
|
||||
$this->widgets,
|
||||
static fn (array $widget): bool => isset($lookup[$widget['widget_id'] ?? ''])
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user