Skip to content

Commit 5018436

Browse files
committed
MAGETWO-32969: [GITHUB] System information error when error is fixed but page wasn't refreshed #919
- Rephrased the notice message content per feedback from product management - Changed the severity level of default message to be "Notice" - Replaced usages of object manager with dependency injections - Code style changes
1 parent 47192cf commit 5018436

File tree

1 file changed

+35
-15
lines changed
  • app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message

1 file changed

+35
-15
lines changed

app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,56 @@
88

99
class ListAction extends \Magento\Backend\App\AbstractAction
1010
{
11+
/**
12+
* @var \Magento\Framework\Json\Helper\Data
13+
*/
14+
protected $jsonHelper;
15+
16+
/**
17+
* @var \Magento\AdminNotification\Model\Resource\System\Message\Collection
18+
*/
19+
protected $messageCollection;
20+
21+
/**
22+
* Initialize ListAction
23+
*
24+
* @param \Magento\Backend\App\Action\Context $context
25+
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
26+
* @param \Magento\AdminNotification\Model\Resource\System\Message\Collection $messageCollection
27+
*/
28+
public function __construct(
29+
\Magento\Backend\App\Action\Context $context,
30+
\Magento\Framework\Json\Helper\Data $jsonHelper,
31+
\Magento\AdminNotification\Model\Resource\System\Message\Collection $messageCollection
32+
) {
33+
$this->jsonHelper = $jsonHelper;
34+
$this->messageCollection = $messageCollection;
35+
parent::__construct($context);
36+
}
37+
1138
/**
1239
* @return void
1340
*/
1441
public function execute()
1542
{
1643
$severity = $this->getRequest()->getParam('severity');
17-
$default = [
18-
'severity' => $severity,
19-
'text' => 'All recent issues have been fixed. '
20-
.'Please refresh the screen for an update.',
21-
];
22-
$messageCollection = $this->_objectManager->get(
23-
'Magento\AdminNotification\Model\Resource\System\Message\Collection'
24-
);
2544
if ($severity) {
26-
$messageCollection->setSeverity($severity);
45+
$this->messageCollection->setSeverity($severity);
2746
}
2847
$result = [];
29-
foreach ($messageCollection->getItems() as $item) {
48+
foreach ($this->messageCollection->getItems() as $item) {
3049
$result[] = [
3150
'severity' => $item->getSeverity(),
3251
'text' => $item->getText(),
3352
];
3453
}
3554
if (empty($result)) {
36-
$result[] = $default;
55+
$result[] = [
56+
'severity' => (string)\Magento\Framework\Notification\MessageInterface::SEVERITY_NOTICE,
57+
'text' => 'You have viewed and resolved all recent system notices. '
58+
. 'Please refresh the web page to clear the notice alert.',
59+
];
3760
}
38-
$this->getResponse()->representJson(
39-
$this->_objectManager->get('Magento\Framework\Json\Helper\Data')
40-
->jsonEncode($result)
41-
);
61+
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
4262
}
4363
}

0 commit comments

Comments
 (0)