Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigLoader.php
Go to the documentation of this file.
1 <?php
9 
13 
15 {
21  protected $_reader;
22 
28  protected $_readerFactory;
29 
35  protected $_cache;
36 
40  private $serializer;
41 
46  public function __construct(
48  \Magento\Framework\ObjectManager\Config\Reader\DomFactory $readerFactory
49  ) {
50  $this->_cache = $cache;
51  $this->_readerFactory = $readerFactory;
52  }
53 
59  protected function _getReader()
60  {
61  if (empty($this->_reader)) {
62  $this->_reader = $this->_readerFactory->create();
63  }
64  return $this->_reader;
65  }
66 
70  public function load($area)
71  {
72  $cacheId = $area . '::DiConfig';
73  $data = $this->_cache->load($cacheId);
74 
75  if (!$data) {
76  $data = $this->_getReader()->read($area);
77  $this->_cache->save($this->getSerializer()->serialize($data), $cacheId);
78  } else {
79  $data = $this->getSerializer()->unserialize($data);
80  }
81 
82  return $data;
83  }
84 
91  private function getSerializer()
92  {
93  if (null === $this->serializer) {
94  $this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->get(Serialize::class);
95  }
96  return $this->serializer;
97  }
98 }
__construct(\Magento\Framework\Config\CacheInterface $cache, \Magento\Framework\ObjectManager\Config\Reader\DomFactory $readerFactory)