Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CleanMedia.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
12 
13 class CleanMedia extends \Magento\Backend\Controller\Adminhtml\Cache implements HttpGetActionInterface
14 {
20  const ADMIN_RESOURCE = 'Magento_Backend::flush_js_css';
21 
27  public function execute()
28  {
29  try {
30  $this->_objectManager->get(\Magento\Framework\View\Asset\MergeService::class)->cleanMergedJsCss();
31  $this->_eventManager->dispatch('clean_media_cache_after');
32  $this->messageManager->addSuccessMessage(__('The JavaScript/CSS cache has been cleaned.'));
33  } catch (LocalizedException $e) {
34  $this->messageManager->addErrorMessage($e->getMessage());
35  } catch (\Exception $e) {
36  $this->messageManager
37  ->addExceptionMessage($e, __('An error occurred while clearing the JavaScript/CSS cache.'));
38  }
39 
41  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
42  return $resultRedirect->setPath('adminhtml/*');
43  }
44 }
__()
Definition: __.php:13