diff --git a/Classes/Configuration/AbstractConfiguration.php b/Classes/Configuration/AbstractConfiguration.php index 2876733..f3bada1 100644 --- a/Classes/Configuration/AbstractConfiguration.php +++ b/Classes/Configuration/AbstractConfiguration.php @@ -5,7 +5,7 @@ class AbstractConfiguration { - public function __construct(array $properties) + public function __construct(array $properties = []) { foreach ($properties as $property => $value) { if (property_exists($this, $property)) { diff --git a/Classes/Configuration/Dashboard.php b/Classes/Configuration/Dashboard.php index 345996c..cf3051c 100644 --- a/Classes/Configuration/Dashboard.php +++ b/Classes/Configuration/Dashboard.php @@ -23,7 +23,7 @@ class Dashboard extends AbstractConfiguration /** * @var string */ - protected $iconIdentifier = 'dashboard-dashboard'; + protected $iconIdentifier = 'dashboard-default'; /** * @var string @@ -45,26 +45,66 @@ public function getIdentifier(): string return $this->identifier; } + /** + * @param string $identifier + */ + public function setIdentifier(string $identifier): void + { + $this->identifier = $identifier; + } + public function getExcludeFromWizard(): bool { return $this->excludeFromWizard; } + /** + * @param bool $excludeFromWizard + */ + public function setExcludeFromWizard(bool $excludeFromWizard): void + { + $this->excludeFromWizard = $excludeFromWizard; + } + public function getIconIdentifier(): string { return $this->iconIdentifier; } + /** + * @param string $iconIdentifier + */ + public function setIconIdentifier(string $iconIdentifier): void + { + $this->iconIdentifier = $iconIdentifier; + } + public function getLabel(): string { return $this->label; } + /** + * @param string $label + */ + public function setLabel(string $label): void + { + $this->label = $label; + } + public function getDescription(): string { return $this->description; } + /** + * @param string $description + */ + public function setDescription(string $description): void + { + $this->description = $description; + } + /** * @return string[] */ @@ -72,4 +112,12 @@ public function getWidgets(): array { return $this->widgets; } + + /** + * @param string[] $widgets + */ + public function setWidgets(array $widgets): void + { + $this->widgets = $widgets; + } } diff --git a/Classes/Configuration/Widget.php b/Classes/Configuration/Widget.php index 6f1105d..0128394 100644 --- a/Classes/Configuration/Widget.php +++ b/Classes/Configuration/Widget.php @@ -30,11 +30,27 @@ public function getIdentifier(): string return $this->identifier; } + /** + * @param string $identifier + */ + public function setIdentifier(string $identifier): void + { + $this->identifier = $identifier; + } + public function getClassname(): string { return $this->className; } + /** + * @param string $className + */ + public function setClassName(string $className): void + { + $this->className = $className; + } + /** * @return string[] */ @@ -42,4 +58,12 @@ public function getGroups(): array { return $this->groups; } + + /** + * @param string[] $groups + */ + public function setGroups(array $groups): void + { + $this->groups = $groups; + } } diff --git a/Classes/Configuration/WidgetGroup.php b/Classes/Configuration/WidgetGroup.php index 42f8854..37ef9f0 100644 --- a/Classes/Configuration/WidgetGroup.php +++ b/Classes/Configuration/WidgetGroup.php @@ -25,8 +25,24 @@ public function getIdentifier(): string return $this->identifier; } + /** + * @param string $identifier + */ + public function setIdentifier(string $identifier): void + { + $this->identifier = $identifier; + } + public function getLabel(): string { return $this->label; } + + /** + * @param string $label + */ + public function setLabel(string $label): void + { + $this->label = $label; + } } diff --git a/Classes/DashboardConfiguration.php b/Classes/DashboardConfiguration.php index d4c841e..2e01569 100644 --- a/Classes/DashboardConfiguration.php +++ b/Classes/DashboardConfiguration.php @@ -62,6 +62,17 @@ class DashboardConfiguration implements SingletonInterface */ protected $packageManager; + /** + * Array of all registered dashboards + * + * @var array + */ + protected $dashboards = []; + + protected $widgetGroups = []; + + protected $widgets = []; + public function __construct(PackageManager $packageManager = null) { $this->packageManager = $packageManager ?? GeneralUtility::makeInstance(PackageManager::class); @@ -98,20 +109,27 @@ public function getWidgetsGroups(): array } /** - * Resolve all dashboard objects which have been found in the filesystem. + * Resolve all dashboard objects which have been found in the filesystem and registered by the API * * @param bool $useCache * @return Dashboard[] */ protected function resolveAllExistingDashboards(bool $useCache = true): array { - $dashboards = []; $dashboardConfiguration = $this->getAllDashboardConfigurationFromFiles($useCache); foreach ($dashboardConfiguration['Dashboard']['Dashboards'] ?? [] as $configuration) { - $dashboards[$configuration['identifier']] = GeneralUtility::makeInstance(Dashboard::class, $configuration); + $this->dashboards[$configuration['identifier']] = GeneralUtility::makeInstance(Dashboard::class, $configuration); } - $this->firstLevelCacheDashboards = $dashboards; - return $dashboards; + $this->firstLevelCacheDashboards = $this->dashboards; + return $this->dashboards; + } + + /** + * @param Dashboard $dashboardConfiguration + */ + public function registerDashboard(Dashboard $dashboardConfiguration): void + { + $this->dashboards[$dashboardConfiguration->getIdentifier()] = $dashboardConfiguration; } /** @@ -122,30 +140,44 @@ protected function resolveAllExistingDashboards(bool $useCache = true): array */ protected function resolveAllExistingWidgets(bool $useCache = true): array { - $widgets = []; $dashboardConfiguration = $this->getAllDashboardConfigurationFromFiles($useCache); foreach ($dashboardConfiguration['Dashboard']['Widgets'] ?? [] as $configuration) { - $widgets[$configuration['identifier']] = GeneralUtility::makeInstance(Widget::class, $configuration); + $this->widgets[$configuration['identifier']] = GeneralUtility::makeInstance(Widget::class, $configuration); } - $this->firstLevelCacheWidgets = $widgets; - return $widgets; + $this->firstLevelCacheWidgets = $this->widgets; + return $this->widgets; } /** - * Resolve all widget groups objects which have been found in the filesystem. + * @param Widget $widgetConfiguration + */ + public function registerWidget(Widget $widgetConfiguration): void + { + $this->widgets[$widgetConfiguration->getIdentifier()] = $widgetConfiguration; + } + + /** + * Resolve all widget groups objects which have been found in the filesystem and registered by the API * * @param bool $useCache - * @return Widget[] + * @return WidgetGroup[] */ protected function resolveAllExistingWidgetGroups(bool $useCache = true): array { - $widgetsGroups = []; $dashboardConfiguration = $this->getAllDashboardConfigurationFromFiles($useCache); foreach ($dashboardConfiguration['Dashboard']['WidgetGroups'] ?? [] as $configuration) { - $widgetsGroups[$configuration['identifier']] = GeneralUtility::makeInstance(WidgetGroup::class, $configuration); + $this->widgetGroups[$configuration['identifier']] = GeneralUtility::makeInstance(WidgetGroup::class, $configuration); } - $this->firstLevelCacheWidgetGroups = $widgetsGroups; - return $widgetsGroups; + $this->firstLevelCacheWidgetGroups = $this->widgetGroups; + return $this->widgetGroups; + } + + /** + * @param WidgetGroup $widgetGroupConfiguration + */ + public function registerWidgetGroup(WidgetGroup $widgetGroupConfiguration): void + { + $this->widgetGroups[$widgetGroupConfiguration->getIdentifier()] = $widgetGroupConfiguration; } /** diff --git a/Resources/Private/Templates/Dashboard/Main.html b/Resources/Private/Templates/Dashboard/Main.html index 3aa68d1..f8e3f07 100644 --- a/Resources/Private/Templates/Dashboard/Main.html +++ b/Resources/Private/Templates/Dashboard/Main.html @@ -8,7 +8,7 @@

- +