FlushAll.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. class FlushAll extends \Magento\Backend\Controller\Adminhtml\Cache implements HttpGetActionInterface
  10. {
  11. /**
  12. * Authorization level of a basic admin session
  13. *
  14. * @see _isAllowed()
  15. */
  16. const ADMIN_RESOURCE = 'Magento_Backend::flush_cache_storage';
  17. /**
  18. * Flush cache storage
  19. *
  20. * @return \Magento\Backend\Model\View\Result\Redirect
  21. */
  22. public function execute()
  23. {
  24. $this->_eventManager->dispatch('adminhtml_cache_flush_all');
  25. /** @var $cacheFrontend \Magento\Framework\Cache\FrontendInterface */
  26. foreach ($this->_cacheFrontendPool as $cacheFrontend) {
  27. $cacheFrontend->getBackend()->clean();
  28. }
  29. $this->messageManager->addSuccessMessage(__("You flushed the cache storage."));
  30. /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
  31. $resultRedirect = $this->resultRedirectFactory->create();
  32. return $resultRedirect->setPath('adminhtml/*');
  33. }
  34. }