From 5d8ecd255051f78007b944a7fb847519b2b1eeb8 Mon Sep 17 00:00:00 2001 From: Oliver Bartsch <bo@cedev.de> Date: Wed, 15 Apr 2020 18:47:59 +0200 Subject: [PATCH] [TASK] Use ButtonUtility in dashboard widgets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: TYPO3com <noreply@typo3.com> Tested-by: Richard Haeser <richard@maxserv.com> Tested-by: Christian Eßl <indy.essl@gmail.com> Reviewed-by: Richard Haeser <richard@maxserv.com> Reviewed-by: Christian Eßl <indy.essl@gmail.com> --- .../dashboard/Classes/Widgets/ListWidget.php | 18 ++---------------- .../dashboard/Classes/Widgets/RssWidget.php | 18 ++---------------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/typo3/sysext/dashboard/Classes/Widgets/ListWidget.php b/typo3/sysext/dashboard/Classes/Widgets/ListWidget.php index cc09c3a0b1a1..09eb2ede5001 100644 --- a/typo3/sysext/dashboard/Classes/Widgets/ListWidget.php +++ b/typo3/sysext/dashboard/Classes/Widgets/ListWidget.php @@ -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; - } } diff --git a/typo3/sysext/dashboard/Classes/Widgets/RssWidget.php b/typo3/sysext/dashboard/Classes/Widgets/RssWidget.php index 30091e7698a8..7870bf5296b3 100644 --- a/typo3/sysext/dashboard/Classes/Widgets/RssWidget.php +++ b/typo3/sysext/dashboard/Classes/Widgets/RssWidget.php @@ -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; - } } -- GitLab