Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MassRefresh.php
Go to the documentation of this file.
1 <?php
8 
11 
13 {
19  const ADMIN_RESOURCE = 'Magento_Backend::refresh_cache_type';
20 
26  public function execute()
27  {
28  try {
29  $types = $this->getRequest()->getParam('types');
30  $updatedTypes = 0;
31  if (!is_array($types)) {
32  $types = [];
33  }
34  $this->_validateTypes($types);
35  foreach ($types as $type) {
36  $this->_cacheTypeList->cleanType($type);
37  $updatedTypes++;
38  }
39  if ($updatedTypes > 0) {
40  $this->messageManager->addSuccessMessage(__("%1 cache type(s) refreshed.", $updatedTypes));
41  }
42  } catch (LocalizedException $e) {
43  $this->messageManager->addErrorMessage($e->getMessage());
44  } catch (\Exception $e) {
45  $this->messageManager->addExceptionMessage($e, __('An error occurred while refreshing cache.'));
46  }
47 
49  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
50  return $resultRedirect->setPath('adminhtml/*');
51  }
52 }
__()
Definition: __.php:13
$type
Definition: item.phtml:13