Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Config.php
Go to the documentation of this file.
1 <?php
7 
11 
18 class Config
19 {
20  const CACHE_ID = 'integration';
21 
25  protected $_configCacheType;
26 
30  protected $_configReader;
31 
37  protected $_integrations;
38 
42  private $serializer;
43 
49  public function __construct(
50  Cache\Type $configCacheType,
51  Config\Reader $configReader,
52  SerializerInterface $serializer = null
53  ) {
54  $this->_configCacheType = $configCacheType;
55  $this->_configReader = $configReader;
56  $this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
57  }
58 
65  public function getIntegrations()
66  {
67  if (null === $this->_integrations) {
68  $integrations = $this->_configCacheType->load(self::CACHE_ID);
69  if ($integrations && is_string($integrations)) {
70  $this->_integrations = $this->serializer->unserialize($integrations);
71  } else {
72  $this->_integrations = $this->_configReader->read();
73  $this->_configCacheType->save(
74  $this->serializer->serialize($this->_integrations),
77  );
78  }
79  }
80  return $this->_integrations;
81  }
82 }
__construct(Cache\Type $configCacheType, Config\Reader $configReader, SerializerInterface $serializer=null)
Definition: Config.php:49