Skip to content

Commit

Permalink
[BUGFIX] Fix data type annotations in WidgetRegistry
Browse files Browse the repository at this point in the history
Resolves: #92530
Releases: master, 10.4
Change-Id: If593ae69ec7862f45eeea7d0c15cebf98462139b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/66112
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
  • Loading branch information
brotkrueml authored and ervaude committed Oct 10, 2020
1 parent be076b6 commit efe48ef
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions typo3/sysext/dashboard/Classes/WidgetRegistry.php
Expand Up @@ -21,6 +21,7 @@
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;

/**
Expand All @@ -34,12 +35,12 @@ class WidgetRegistry implements SingletonInterface
protected $container;

/**
* @var WidgetInterface[]
* @var WidgetConfigurationInterface[]
*/
private $widgets = [];

/**
* @var array
* @var array<string, WidgetConfigurationInterface[]>
*/
private $widgetsPerWidgetGroup = [];

Expand All @@ -48,11 +49,17 @@ public function __construct(ContainerInterface $container)
$this->container = $container;
}

/**
* @return WidgetConfigurationInterface[]
*/
public function getAvailableWidgets(): array
{
return $this->checkPermissionOfWidgets($this->widgets);
}

/**
* @return WidgetConfigurationInterface[]
*/
public function getAllWidgets(): array
{
return $this->widgets;
Expand All @@ -70,6 +77,10 @@ public function getAvailableWidget(string $identifier): WidgetInterface
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)) {
Expand All @@ -91,6 +102,10 @@ public function registerWidget(string $serviceName): void
}
}

/**
* @param WidgetConfigurationInterface[] $widgets
* @return WidgetConfigurationInterface[]
*/
protected function checkPermissionOfWidgets(array $widgets): array
{
return array_filter($widgets, function ($identifier) {
Expand Down

0 comments on commit efe48ef

Please sign in to comment.