Skip to content

Commit

Permalink
MAGETWO-32969: [GITHUB] System information error when error is fixed …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
marcozheng committed Mar 14, 2015
1 parent 47192cf commit 5018436
Showing 1 changed file with 35 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,56 @@

class ListAction extends \Magento\Backend\App\AbstractAction
{
/**
* @var \Magento\Framework\Json\Helper\Data
*/
protected $jsonHelper;

/**
* @var \Magento\AdminNotification\Model\Resource\System\Message\Collection
*/
protected $messageCollection;

/**
* Initialize ListAction
*
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
* @param \Magento\AdminNotification\Model\Resource\System\Message\Collection $messageCollection
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\Json\Helper\Data $jsonHelper,
\Magento\AdminNotification\Model\Resource\System\Message\Collection $messageCollection
) {
$this->jsonHelper = $jsonHelper;
$this->messageCollection = $messageCollection;
parent::__construct($context);
}

/**
* @return void
*/
public function execute()
{
$severity = $this->getRequest()->getParam('severity');
$default = [
'severity' => $severity,
'text' => 'All recent issues have been fixed. '
.'Please refresh the screen for an update.',
];
$messageCollection = $this->_objectManager->get(
'Magento\AdminNotification\Model\Resource\System\Message\Collection'
);
if ($severity) {
$messageCollection->setSeverity($severity);
$this->messageCollection->setSeverity($severity);
}
$result = [];
foreach ($messageCollection->getItems() as $item) {
foreach ($this->messageCollection->getItems() as $item) {
$result[] = [
'severity' => $item->getSeverity(),
'text' => $item->getText(),
];
}
if (empty($result)) {
$result[] = $default;
$result[] = [
'severity' => (string)\Magento\Framework\Notification\MessageInterface::SEVERITY_NOTICE,
'text' => 'You have viewed and resolved all recent system notices. '
. 'Please refresh the web page to clear the notice alert.',
];
}
$this->getResponse()->representJson(
$this->_objectManager->get('Magento\Framework\Json\Helper\Data')
->jsonEncode($result)
);
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
}
}

0 comments on commit 5018436

Please sign in to comment.