Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IntegrationConfig.php
Go to the documentation of this file.
1 <?php
8 
13 
21 {
22  const CACHE_ID = 'integration-api';
23 
27  protected $_configCacheType;
28 
32  protected $_configReader;
33 
39  protected $_integrations;
40 
44  private $serializer;
45 
51  public function __construct(
52  TypeIntegration $configCacheType,
53  Reader $configReader,
54  SerializerInterface $serializer = null
55  ) {
56  $this->_configCacheType = $configCacheType;
57  $this->_configReader = $configReader;
58  $this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
59  }
60 
67  public function getIntegrations()
68  {
69  if (null === $this->_integrations) {
70  $integrations = $this->_configCacheType->load(self::CACHE_ID);
71  if ($integrations && is_string($integrations)) {
72  $this->_integrations = $this->serializer->unserialize($integrations);
73  } else {
74  $this->_integrations = $this->_configReader->read();
75  $this->_configCacheType->save(
76  $this->serializer->serialize($this->_integrations),
79  );
80  }
81  }
82  return $this->_integrations;
83  }
84 }
__construct(TypeIntegration $configCacheType, Reader $configReader, SerializerInterface $serializer=null)