Dismiss.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\AsynchronousOperations\Controller\Adminhtml\Notification;
  7. use Magento\AsynchronousOperations\Model\BulkNotificationManagement;
  8. use Magento\Backend\App\Action\Context;
  9. use Magento\Backend\App\Action;
  10. use Magento\Framework\Controller\ResultFactory;
  11. /**
  12. * Class Bulk Notification Dismiss Controller
  13. */
  14. class Dismiss extends Action
  15. {
  16. /**
  17. * @var BulkNotificationManagement
  18. */
  19. private $notificationManagement;
  20. /**
  21. * Class constructor.
  22. *
  23. * @param Context $context
  24. * @param BulkNotificationManagement $notificationManagement
  25. */
  26. public function __construct(
  27. Context $context,
  28. BulkNotificationManagement $notificationManagement
  29. ) {
  30. parent::__construct($context);
  31. $this->notificationManagement = $notificationManagement;
  32. }
  33. /**
  34. * @inheritDoc
  35. */
  36. protected function _isAllowed()
  37. {
  38. return $this->_authorization->isAllowed('Magento_Logging::system_magento_logging_bulk_operations');
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function execute()
  44. {
  45. $bulkUuids = [];
  46. foreach ((array)$this->getRequest()->getParam('uuid', []) as $bulkUuid) {
  47. $bulkUuids[] = (string)$bulkUuid;
  48. }
  49. $isAcknowledged = $this->notificationManagement->acknowledgeBulks($bulkUuids);
  50. /** @var \Magento\Framework\Controller\Result\Json $result */
  51. $result = $this->resultFactory->create(ResultFactory::TYPE_JSON);
  52. if (!$isAcknowledged) {
  53. $result->setHttpResponseCode(400);
  54. }
  55. return $result;
  56. }
  57. }