Commit b9d5cf14 authored by Patrick Schriner's avatar Patrick Schriner Committed by Morton Jonuschat
Browse files

[BUGFIX] Repair System Information Panel extendibility

Contrary to the documentation given for extending the System Information
Panel via SignalSlot only a single item can be added for each slot due to
improper use of the SignalSlot pattern. The return value of both signals is
assumed to be only one item. This patch passes the Controller as an argument
and adds two methods to add items.

The two signals were marked as internal, so this is not considered
a breaking patch.

Resolves: #70567
Releases: master, 7.6
Change-Id: I268296860ac2f0eb2344f84604a096999bdccac0
Reviewed-on: https://review.typo3.org/43973


Reviewed-by: default avatarSusanne Moog <typo3@susannemoog.de>
Tested-by: default avatarSusanne Moog <typo3@susannemoog.de>
Reviewed-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
parent 647c493b
...@@ -278,11 +278,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface ...@@ -278,11 +278,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
*/ */
protected function emitGetSystemInformation() protected function emitGetSystemInformation()
{ {
// @internal This API is subject to be rebuilt from scratch anytime. Do not use in extensions! $this->getSignalSlotDispatcher()->dispatch(__CLASS__, 'getSystemInformation', array($this));
list($systemInformation) = $this->getSignalSlotDispatcher()->dispatch(__CLASS__, 'getSystemInformation', array(array()));
if (!empty($systemInformation)) {
$this->systemInformation[] = $systemInformation;
}
} }
/** /**
...@@ -292,25 +288,52 @@ class SystemInformationToolbarItem implements ToolbarItemInterface ...@@ -292,25 +288,52 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
*/ */
protected function emitLoadMessages() protected function emitLoadMessages()
{ {
// @internal This API is subject to be rebuilt from scratch anytime. Do not use in extensions! $this->getSignalSlotDispatcher()->dispatch(__CLASS__, 'loadMessages', array($this));
list($message) = $this->getSignalSlotDispatcher()->dispatch(__CLASS__, 'loadMessages', array(array())); }
if (empty($message)) {
return;
}
// increase counter /**
if (isset($message['count']) && $this->totalCount < $this->maximumCountInBadge) { * Add a system message.
$this->totalCount += (int)$message['count']; * This is a callback method for signal receivers.
} *
* @param string $text The text to be displayed
* @param string $status The status of this system message
* @param int $count Will be added to the total count
* @param string $module The associated module
*/
public function addSystemMessage($text, $status = InformationStatus::STATUS_OK, $count = 0, $module = '')
{
$this->totalCount += (int)$count;
/** @var InformationStatus $messageSeverity */ /** @var InformationStatus $messageSeverity */
$messageSeverity = InformationStatus::cast($message['status']); $messageSeverity = InformationStatus::cast($status);
// define the severity for the badge // define the severity for the badge
if ($messageSeverity->isGreaterThan($this->highestSeverity)) { if ($messageSeverity->isGreaterThan($this->highestSeverity)) {
$this->highestSeverity = $messageSeverity; $this->highestSeverity = $messageSeverity;
} }
$this->systemMessages[] = $message; $this->systemMessages[] = array(
'module' => $module,
'count' => (int)$count,
'status' => $messageSeverity,
'text' => $text
);
}
/**
* Add a system information.
* This is a callback method for signal receivers.
*
* @param string $title The title of this system information
* @param string $value The associated value
* @param string $icon The icon html
*/
public function addSystemInformation($title, $value, $icon)
{
$this->systemInformation[] = array(
'title' => $title,
'value' => $value,
'icon' => $icon
);
} }
/** /**
......
...@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Belog\Controller; ...@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Belog\Controller;
*/ */
use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus; use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem;
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Belog\Domain\Model\Constraint; use TYPO3\CMS\Belog\Domain\Model\Constraint;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
...@@ -27,9 +28,9 @@ class SystemInformationController extends AbstractController ...@@ -27,9 +28,9 @@ class SystemInformationController extends AbstractController
/** /**
* Modifies the SystemInformation array * Modifies the SystemInformation array
* *
* @return NULL|array * @param SystemInformationToolbarItem $systemInformationToolbarItem
*/ */
public function appendMessage() public function appendMessage(SystemInformationToolbarItem $systemInformationToolbarItem)
{ {
$constraint = $this->getConstraintFromBeUserData(); $constraint = $this->getConstraintFromBeUserData();
if ($constraint === null) { if ($constraint === null) {
...@@ -50,16 +51,13 @@ class SystemInformationController extends AbstractController ...@@ -50,16 +51,13 @@ class SystemInformationController extends AbstractController
$count = $this->getDatabaseConnection()->exec_SELECTcountRows('error', 'sys_log', 'tstamp >= ' . $timestamp . ' AND error IN(-1,1,2)'); $count = $this->getDatabaseConnection()->exec_SELECTcountRows('error', 'sys_log', 'tstamp >= ' . $timestamp . ' AND error IN(-1,1,2)');
if ($count > 0) { if ($count > 0) {
return array( $systemInformationToolbarItem->addSystemMessage(
array( sprintf(LocalizationUtility::translate('systemmessage.errorsInPeriod', 'belog'), $count, BackendUtility::getModuleUrl('system_BelogLog')),
'module' => 'system_BelogLog', InformationStatus::STATUS_ERROR,
'count' => $count, $count,
'status' => InformationStatus::STATUS_ERROR, 'system_BelogLog'
'text' => sprintf(LocalizationUtility::translate('systemmessage.errorsInPeriod', 'belog'), $count, BackendUtility::getModuleUrl('system_BelogLog'))
)
); );
} }
return null;
} }
/** /**
......
Supports Markdown
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