Skip to content
Snippets Groups Projects
Commit 5d8ecd25 authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Christian Eßl
Browse files

[TASK] Use ButtonUtility in dashboard widgets

Removed duplicated code fragments by using the ButtonUtility
consistently also for ListWidget and RssWidget.

Resolves: #91051
Releases: master
Change-Id: Id7b323d16d74e07ff1b68fce73a52110dbdc03d9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64189


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarRichard Haeser <richard@maxserv.com>
Tested-by: default avatarChristian Eßl <indy.essl@gmail.com>
Reviewed-by: default avatarRichard Haeser <richard@maxserv.com>
Reviewed-by: default avatarChristian Eßl <indy.essl@gmail.com>
parent 682873dd
Branches
Tags
No related merge requests found
......@@ -17,6 +17,7 @@ declare(strict_types=1);
namespace TYPO3\CMS\Dashboard\Widgets;
use TYPO3\CMS\Dashboard\Utility\ButtonUtility;
use TYPO3\CMS\Dashboard\Widgets\Interfaces\ButtonProviderInterface;
use TYPO3\CMS\Dashboard\Widgets\Interfaces\ListDataProviderInterface;
use TYPO3\CMS\Dashboard\Widgets\Interfaces\WidgetConfigurationInterface;
......@@ -80,7 +81,7 @@ class ListWidget implements WidgetInterface
$this->view->assignMultiple([
'items' => $this->getItems(),
'options' => $this->options,
'button' => $this->getButton(),
'button' => ButtonUtility::generateButtonConfig($this->buttonProvider),
'configuration' => $this->configuration,
]);
return $this->view->render();
......@@ -90,19 +91,4 @@ class ListWidget implements WidgetInterface
{
return $this->dataProvider->getItems();
}
private function getButton(): array
{
$button = [];
if ($this->buttonProvider instanceof ButtonProviderInterface && $this->buttonProvider->getTitle() && $this->buttonProvider->getLink()) {
$button = [
'text' => $this->buttonProvider->getTitle(),
'link' => $this->buttonProvider->getLink(),
'target' => $this->buttonProvider->getTarget(),
];
}
return $button;
}
}
......@@ -19,6 +19,7 @@ namespace TYPO3\CMS\Dashboard\Widgets;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface as Cache;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Dashboard\Utility\ButtonUtility;
use TYPO3\CMS\Dashboard\Widgets\Interfaces\ButtonProviderInterface;
use TYPO3\CMS\Dashboard\Widgets\Interfaces\WidgetConfigurationInterface;
use TYPO3\CMS\Dashboard\Widgets\Interfaces\WidgetInterface;
......@@ -91,7 +92,7 @@ class RssWidget implements WidgetInterface
$this->view->assignMultiple([
'items' => $this->getRssItems(),
'options' => $this->options,
'button' => $this->getButton(),
'button' => ButtonUtility::generateButtonConfig($this->buttonProvider),
'configuration' => $this->configuration,
]);
return $this->view->render();
......@@ -127,19 +128,4 @@ class RssWidget implements WidgetInterface
return $items;
}
private function getButton(): array
{
$button = [];
if ($this->buttonProvider instanceof ButtonProviderInterface && $this->buttonProvider->getTitle() && $this->buttonProvider->getLink()) {
$button = [
'text' => $this->buttonProvider->getTitle(),
'link' => $this->buttonProvider->getLink(),
'target' => $this->buttonProvider->getTarget(),
];
}
return $button;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment