Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CacheOutdated.php
Go to the documentation of this file.
1 <?php
7 
13 {
17  protected $_urlBuilder;
18 
22  protected $_authorization;
23 
27  protected $_cacheTypeList;
28 
34  public function __construct(
35  \Magento\Framework\AuthorizationInterface $authorization,
36  \Magento\Framework\UrlInterface $urlBuilder,
37  \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
38  ) {
39  $this->_authorization = $authorization;
40  $this->_urlBuilder = $urlBuilder;
41  $this->_cacheTypeList = $cacheTypeList;
42  }
43 
49  protected function _getCacheTypesForRefresh()
50  {
51  $output = [];
52  foreach ($this->_cacheTypeList->getInvalidated() as $type) {
53  $output[] = $type->getCacheType();
54  }
55  return $output;
56  }
57 
63  public function getIdentity()
64  {
65  return md5('cache' . implode(':', $this->_getCacheTypesForRefresh()));
66  }
67 
73  public function isDisplayed()
74  {
75  return $this->_authorization->isAllowed(
76  'Magento_Backend::cache'
77  ) && count(
79  ) > 0;
80  }
81 
87  public function getText()
88  {
89  $cacheTypes = implode(', ', $this->_getCacheTypesForRefresh());
90  $message = __('One or more of the Cache Types are invalidated: %1. ', $cacheTypes) . ' ';
91  $url = $this->_urlBuilder->getUrl('adminhtml/cache');
92  $message .= __('Please go to <a href="%1">Cache Management</a> and refresh cache types.', $url);
93  return $message;
94  }
95 
101  public function getLink()
102  {
103  return $this->_urlBuilder->getUrl('adminhtml/cache');
104  }
105 
111  public function getSeverity()
112  {
113  return \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL;
114  }
115 }
__()
Definition: __.php:13
$message
$type
Definition: item.phtml:13
__construct(\Magento\Framework\AuthorizationInterface $authorization, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList)