From 089e5cd2f3f77c40331be3d73b88a01ebc84403b Mon Sep 17 00:00:00 2001 From: Richard Haeser Date: Tue, 26 Nov 2019 21:32:01 +0100 Subject: [PATCH 1/4] [FEATURE] Register dashboards by PHP API --- .../Configuration/AbstractConfiguration.php | 2 +- Classes/Configuration/Dashboard.php | 50 ++++++++++++++++++- Classes/DashboardConfiguration.php | 22 ++++++-- .../Private/Templates/Dashboard/Main.html | 2 +- 4 files changed, 69 insertions(+), 7 deletions(-) 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/DashboardConfiguration.php b/Classes/DashboardConfiguration.php index d4c841e..de9a882 100644 --- a/Classes/DashboardConfiguration.php +++ b/Classes/DashboardConfiguration.php @@ -62,6 +62,13 @@ class DashboardConfiguration implements SingletonInterface */ protected $packageManager; + /** + * Array of all registered dashboards + * + * @var array + */ + protected $dashboards = []; + public function __construct(PackageManager $packageManager = null) { $this->packageManager = $packageManager ?? GeneralUtility::makeInstance(PackageManager::class); @@ -105,13 +112,20 @@ public function getWidgetsGroups(): array */ 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 $dashboardObject + */ + public function registerDashboard(Dashboard $dashboardObject): void + { + $this->dashboards[$dashboardObject->getIdentifier()] = $dashboardObject; } /** 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 @@

- + From b0da95a0f057eff6e969a7afd642d68d84901f1b Mon Sep 17 00:00:00 2001 From: Richard Haeser Date: Tue, 26 Nov 2019 21:55:04 +0100 Subject: [PATCH 2/4] [FEATURE] Register widgets and widgetGroups by PHP API --- Classes/Configuration/Widget.php | 24 ++++++++++++++ Classes/Configuration/WidgetGroup.php | 16 ++++++++++ Classes/DashboardConfiguration.php | 46 +++++++++++++++++++-------- 3 files changed, 72 insertions(+), 14 deletions(-) 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 de9a882..2e01569 100644 --- a/Classes/DashboardConfiguration.php +++ b/Classes/DashboardConfiguration.php @@ -69,6 +69,10 @@ class DashboardConfiguration implements SingletonInterface */ protected $dashboards = []; + protected $widgetGroups = []; + + protected $widgets = []; + public function __construct(PackageManager $packageManager = null) { $this->packageManager = $packageManager ?? GeneralUtility::makeInstance(PackageManager::class); @@ -105,7 +109,7 @@ 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[] @@ -121,11 +125,11 @@ protected function resolveAllExistingDashboards(bool $useCache = true): array } /** - * @param Dashboard $dashboardObject + * @param Dashboard $dashboardConfiguration */ - public function registerDashboard(Dashboard $dashboardObject): void + public function registerDashboard(Dashboard $dashboardConfiguration): void { - $this->dashboards[$dashboardObject->getIdentifier()] = $dashboardObject; + $this->dashboards[$dashboardConfiguration->getIdentifier()] = $dashboardConfiguration; } /** @@ -136,30 +140,44 @@ public function registerDashboard(Dashboard $dashboardObject): void */ 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; + } + + /** + * @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. + * 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; } /** From 4396f3678119b4de961ca64af30a890138c64bb4 Mon Sep 17 00:00:00 2001 From: Richard Haeser Date: Tue, 26 Nov 2019 22:14:32 +0100 Subject: [PATCH 3/4] [TASK] Add conflict with symfony/yaml v4.4.0 --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 4b8683f..08cf3dd 100644 --- a/composer.json +++ b/composer.json @@ -46,6 +46,9 @@ "symfony/finder": "^4.3", "typo3fluid/fluid": "^2.5" }, + "conflict": { + "symfony/yaml": "4.4.0" + }, "autoload": { "psr-4": { "FriendsOfTYPO3\\Dashboard\\": "Classes/" From 48b3a6b467d5f1180924bccfb3f9431b2c73ebe9 Mon Sep 17 00:00:00 2001 From: Richard Haeser Date: Tue, 26 Nov 2019 22:27:02 +0100 Subject: [PATCH 4/4] [REVERT][TASK] Add conflict with symfony/yaml v4.4.0 --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index 08cf3dd..4b8683f 100644 --- a/composer.json +++ b/composer.json @@ -46,9 +46,6 @@ "symfony/finder": "^4.3", "typo3fluid/fluid": "^2.5" }, - "conflict": { - "symfony/yaml": "4.4.0" - }, "autoload": { "psr-4": { "FriendsOfTYPO3\\Dashboard\\": "Classes/"