Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Remove.php
Go to the documentation of this file.
1 <?php
8 
10 {
11 
17  const ADMIN_RESOURCE = 'Magento_AdminNotification::adminnotification_remove';
18 
22  public function execute()
23  {
24  if ($id = $this->getRequest()->getParam('id')) {
25  $model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id);
26 
27  if (!$model->getId()) {
28  $this->_redirect('adminhtml/*/');
29  return;
30  }
31 
32  try {
33  $model->setIsRemove(1)->save();
34  $this->messageManager->addSuccessMessage(__('The message has been removed.'));
35  } catch (\Magento\Framework\Exception\LocalizedException $e) {
36  $this->messageManager->addErrorMessage($e->getMessage());
37  } catch (\Exception $e) {
38  $this->messageManager->addExceptionMessage(
39  $e,
40  __("We couldn't remove the messages because of an error.")
41  );
42  }
43 
44  $this->_redirect('adminhtml/*/');
45  return;
46  }
47  $this->_redirect('adminhtml/*/');
48  }
49 }
$id
Definition: fieldset.phtml:14
__()
Definition: __.php:13