Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ServiceConfig.php
Go to the documentation of this file.
1 <?php
7 declare(strict_types=1);
8 
10 
15 
22 {
23  const CACHE_ID = 'webapi_async_service_config';
24 
28  private $cache;
29 
33  private $configReader;
34 
38  private $services;
39 
43  private $serializer;
44 
52  public function __construct(
53  WebapiCache $cache,
54  Reader $configReader,
55  SerializerInterface $serializer
56  ) {
57  $this->cache = $cache;
58  $this->configReader = $configReader;
59  $this->serializer = $serializer;
60  }
61 
67  public function getServices()
68  {
69  if (null === $this->services) {
70  $services = $this->cache->load(self::CACHE_ID);
71  if ($services && is_string($services)) {
72  $this->services = $this->serializer->unserialize($services);
73  } else {
74  $this->services = $this->configReader->read();
75  $this->cache->save($this->serializer->serialize($this->services), self::CACHE_ID);
76  }
77  }
78  return $this->services;
79  }
80 }
__construct(WebapiCache $cache, Reader $configReader, SerializerInterface $serializer)