Cache.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class Cache extends \Magento\Backend\Block\Widget\Grid\Container
  12. {
  13. /**
  14. * Class constructor
  15. *
  16. * @return void
  17. */
  18. protected function _construct()
  19. {
  20. $this->_controller = 'cache';
  21. $this->_headerText = __('Cache Storage Management');
  22. parent::_construct();
  23. $this->buttonList->remove('add');
  24. if ($this->_authorization->isAllowed('Magento_Backend::flush_magento_cache')) {
  25. $this->buttonList->add(
  26. 'flush_magento',
  27. [
  28. 'label' => __('Flush Magento Cache'),
  29. 'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() . '\')',
  30. 'class' => 'primary flush-cache-magento'
  31. ]
  32. );
  33. }
  34. if ($this->_authorization->isAllowed('Magento_Backend::flush_cache_storage')) {
  35. $message = __('The cache storage may contain additional data. Are you sure that you want to flush it?');
  36. $this->buttonList->add(
  37. 'flush_system',
  38. [
  39. 'label' => __('Flush Cache Storage'),
  40. 'onclick' => 'confirmSetLocation(\'' . $message . '\', \'' . $this->getFlushStorageUrl() . '\')',
  41. 'class' => 'flush-cache-storage'
  42. ]
  43. );
  44. }
  45. }
  46. /**
  47. * Get url for clean cache storage
  48. *
  49. * @return string
  50. */
  51. public function getFlushStorageUrl()
  52. {
  53. return $this->getUrl('adminhtml/*/flushAll');
  54. }
  55. /**
  56. * Get url for clean cache storage
  57. *
  58. * @return string
  59. */
  60. public function getFlushSystemUrl()
  61. {
  62. return $this->getUrl('adminhtml/*/flushSystem');
  63. }
  64. }