Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Cache.php
Go to the documentation of this file.
1 <?php
8 
11 
12 abstract class Cache extends Action
13 {
19  const ADMIN_RESOURCE = 'Magento_Backend::cache';
20 
24  protected $_cacheTypeList;
25 
29  protected $_cacheState;
30 
35 
39  protected $resultPageFactory;
40 
48  public function __construct(
49  Action\Context $context,
50  \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
51  \Magento\Framework\App\Cache\StateInterface $cacheState,
52  \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool,
53  \Magento\Framework\View\Result\PageFactory $resultPageFactory
54  ) {
55  parent::__construct($context);
56  $this->_cacheTypeList = $cacheTypeList;
57  $this->_cacheState = $cacheState;
58  $this->_cacheFrontendPool = $cacheFrontendPool;
59  $this->resultPageFactory = $resultPageFactory;
60  }
61 
69  protected function _validateTypes(array $types)
70  {
71  if (empty($types)) {
72  return;
73  }
74  $allTypes = array_keys($this->_cacheTypeList->getTypes());
75  $invalidTypes = array_diff($types, $allTypes);
76  if (count($invalidTypes) > 0) {
77  throw new LocalizedException(__('These cache type(s) don\'t exist: %1', join(', ', $invalidTypes)));
78  }
79  }
80 }
__()
Definition: __.php:13
__construct(Action\Context $context, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Cache\StateInterface $cacheState, \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool, \Magento\Framework\View\Result\PageFactory $resultPageFactory)
Definition: Cache.php:48