ItemsUpdater.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\Order\Grid\Massaction;
  7. class ItemsUpdater implements \Magento\Framework\View\Layout\Argument\UpdaterInterface
  8. {
  9. /**
  10. * @var \Magento\Framework\AuthorizationInterface
  11. */
  12. protected $_authorization;
  13. /**
  14. * @param \Magento\Framework\AuthorizationInterface $authorization
  15. */
  16. public function __construct(\Magento\Framework\AuthorizationInterface $authorization)
  17. {
  18. $this->_authorization = $authorization;
  19. }
  20. /**
  21. * Remove massaction items in case they disallowed for user
  22. * @param mixed $argument
  23. * @return mixed
  24. */
  25. public function update($argument)
  26. {
  27. if (false === $this->_authorization->isAllowed('Magento_Sales::cancel')) {
  28. unset($argument['cancel_order']);
  29. }
  30. if (false === $this->_authorization->isAllowed('Magento_Sales::hold')) {
  31. unset($argument['hold_order']);
  32. }
  33. if (false === $this->_authorization->isAllowed('Magento_Sales::unhold')) {
  34. unset($argument['unhold_order']);
  35. }
  36. return $argument;
  37. }
  38. }