FlushSystem.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 FlushSystem 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_magento_cache';
  17. /**
  18. * Flush all magento cache
  19. *
  20. * @return \Magento\Backend\Model\View\Result\Redirect
  21. */
  22. public function execute()
  23. {
  24. /** @var $cacheFrontend \Magento\Framework\Cache\FrontendInterface */
  25. foreach ($this->_cacheFrontendPool as $cacheFrontend) {
  26. $cacheFrontend->clean();
  27. }
  28. $this->_eventManager->dispatch('adminhtml_cache_flush_system');
  29. $this->messageManager->addSuccessMessage(__("The Magento cache storage has been flushed."));
  30. /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
  31. $resultRedirect = $this->resultRedirectFactory->create();
  32. return $resultRedirect->setPath('adminhtml/*');
  33. }
  34. }