Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractMassAction.php
Go to the documentation of this file.
1 <?php
7 
14 
21 {
25  const ADMIN_RESOURCE = 'Magento_Sales::actions_edit';
26 
30  protected $redirectUrl = '*/*/';
31 
35  protected $filter;
36 
40  protected $collectionFactory;
41 
46  public function __construct(Context $context, Filter $filter)
47  {
48  parent::__construct($context);
49  $this->filter = $filter;
50  }
51 
58  public function execute()
59  {
60  try {
61  $collection = $this->filter->getCollection($this->collectionFactory->create());
62  return $this->massAction($collection);
63  } catch (\Exception $e) {
64  $this->messageManager->addErrorMessage($e->getMessage());
66  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
67  return $resultRedirect->setPath($this->redirectUrl);
68  }
69  }
70 
77  protected function getComponentRefererUrl()
78  {
79  return $this->filter->getComponentRefererUrl() ?: 'sales/*/';
80  }
81 
88  abstract protected function massAction(AbstractCollection $collection);
89 }