Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
ServiceConfig Class Reference

Public Member Functions

 __construct (WebapiCache $cache, Reader $configReader, SerializerInterface $serializer)
 
 getServices ()
 

Data Fields

const CACHE_ID = 'webapi_async_service_config'
 

Detailed Description

This class gives access to consolidated web API configuration from <Module_Name>/etc/webapi_async.xml files.

@api

Definition at line 21 of file ServiceConfig.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( WebapiCache  $cache,
Reader  $configReader,
SerializerInterface  $serializer 
)

Initialize dependencies.

Parameters
WebapiCache$cache
Reader$configReader
SerializerInterface$serializer

Definition at line 52 of file ServiceConfig.php.

56  {
57  $this->cache = $cache;
58  $this->configReader = $configReader;
59  $this->serializer = $serializer;
60  }

Member Function Documentation

◆ getServices()

getServices ( )

Return services loaded from cache if enabled or from files merged previously

Returns
array

Definition at line 67 of file ServiceConfig.php.

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  }

Field Documentation

◆ CACHE_ID

const CACHE_ID = 'webapi_async_service_config'

Definition at line 23 of file ServiceConfig.php.


The documentation for this class was generated from the following file: