Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Initial.php
Go to the documentation of this file.
1 <?php
9 
12 
13 class Initial
14 {
18  const CACHE_ID = 'initial_config';
19 
25  protected $_data = [];
26 
32  protected $_metadata = [];
33 
37  private $serializer;
38 
46  public function __construct(
47  \Magento\Framework\App\Config\Initial\Reader $reader,
48  \Magento\Framework\App\Cache\Type\Config $cache,
49  SerializerInterface $serializer = null
50  ) {
51  $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
52  ->get(SerializerInterface::class);
53  $data = $cache->load(self::CACHE_ID);
54  if (!$data) {
55  $data = $reader->read();
56  $cache->save($this->serializer->serialize($data), self::CACHE_ID);
57  } else {
58  $data = $this->serializer->unserialize($data);
59  }
60  $this->_data = $data['data'];
61  $this->_metadata = $data['metadata'];
62  }
63 
70  public function getData($scope)
71  {
72  list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null);
73 
74  if (ScopeConfigInterface::SCOPE_TYPE_DEFAULT == $scopeType) {
75  return $this->_data[$scopeType] ?? [];
76  } elseif ($scopeCode) {
77  return $this->_data[$scopeType][$scopeCode] ?? [];
78  }
79  return [];
80  }
81 
87  public function getMetadata()
88  {
89  return $this->_metadata;
90  }
91 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
__construct(\Magento\Framework\App\Config\Initial\Reader $reader, \Magento\Framework\App\Cache\Type\Config $cache, SerializerInterface $serializer=null)
Definition: Initial.php:46