CleanStaticFiles.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Backend\Controller\Adminhtml\Cache;
  8. use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
  9. use Magento\Framework\Controller\ResultFactory;
  10. class CleanStaticFiles extends \Magento\Backend\Controller\Adminhtml\Cache implements HttpGetActionInterface
  11. {
  12. /**
  13. * Authorization level of a basic admin session
  14. *
  15. * @see _isAllowed()
  16. */
  17. const ADMIN_RESOURCE = 'Magento_Backend::flush_static_files';
  18. /**
  19. * Clean static files cache
  20. *
  21. * @return \Magento\Backend\Model\View\Result\Redirect
  22. */
  23. public function execute()
  24. {
  25. $this->_objectManager->get(\Magento\Framework\App\State\CleanupFiles::class)->clearMaterializedViewFiles();
  26. $this->_eventManager->dispatch('clean_static_files_cache_after');
  27. $this->messageManager->addSuccessMessage(__('The static files cache has been cleaned.'));
  28. /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
  29. $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
  30. return $resultRedirect->setPath('adminhtml/*');
  31. }
  32. }