From 571ae71a89aa69b259e369310e9fed2734af46e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20M=C3=BCller?= <typo3@krue.ml> Date: Fri, 9 Oct 2020 17:41:22 +0200 Subject: [PATCH] [BUGFIX] Fix data type annotations in WidgetRegistry Resolves: #92530 Releases: master, 10.4 Change-Id: If593ae69ec7862f45eeea7d0c15cebf98462139b Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/66096 Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Alexander Schnitzler <git@alexanderschnitzler.de> Tested-by: Daniel Goerz <daniel.goerz@posteo.de> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Alexander Schnitzler <git@alexanderschnitzler.de> Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de> --- .../dashboard/Classes/WidgetRegistry.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/dashboard/Classes/WidgetRegistry.php b/typo3/sysext/dashboard/Classes/WidgetRegistry.php index 2ab288490040..cb8e24e0e78d 100644 --- a/typo3/sysext/dashboard/Classes/WidgetRegistry.php +++ b/typo3/sysext/dashboard/Classes/WidgetRegistry.php @@ -21,6 +21,7 @@ use Psr\Container\ContainerInterface; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; +use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface; use TYPO3\CMS\Dashboard\Widgets\WidgetInterface; /** @@ -34,12 +35,12 @@ class WidgetRegistry implements SingletonInterface protected $container; /** - * @var WidgetInterface[] + * @var WidgetConfigurationInterface[] */ private $widgets = []; /** - * @var array + * @var array<string, WidgetConfigurationInterface[]> */ private $widgetsPerWidgetGroup = []; @@ -48,11 +49,17 @@ class WidgetRegistry implements SingletonInterface $this->container = $container; } + /** + * @return WidgetConfigurationInterface[] + */ public function getAvailableWidgets(): array { return $this->checkPermissionOfWidgets($this->widgets); } + /** + * @return WidgetConfigurationInterface[] + */ public function getAllWidgets(): array { return $this->widgets; @@ -70,6 +77,10 @@ class WidgetRegistry implements SingletonInterface throw new \InvalidArgumentException('Requested widget "' . $identifier . '" does not exist.', 1584777201); } + /** + * @param string $widgetGroupIdentifier + * @return WidgetConfigurationInterface[] + */ public function getAvailableWidgetsForWidgetGroup(string $widgetGroupIdentifier): array { if (!array_key_exists($widgetGroupIdentifier, $this->widgetsPerWidgetGroup)) { @@ -91,6 +102,10 @@ class WidgetRegistry implements SingletonInterface } } + /** + * @param WidgetConfigurationInterface[] $widgets + * @return WidgetConfigurationInterface[] + */ protected function checkPermissionOfWidgets(array $widgets): array { return array_filter($widgets, function ($identifier) { -- GitLab