Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Config Class Reference
Inheritance diagram for Config:
ConfigInterface

Public Member Functions

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

Data Fields

const CACHE_ID = 'webapi_config'
 
const SERVICE_CLASS_PATTERN = '/^(.+?)\\\\(.+?)\\\\Service\\\\(V\d+)+(\\\\.+)Interface$/'
 
const API_PATTERN = '/^(.+?)\\\\(.+?)\\\\Api(\\\\.+)Interface$/'
 

Protected Attributes

 $cache
 
 $configReader
 
 $services
 

Detailed Description

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

@api

Since
100.0.2

Definition at line 20 of file Config.php.

Constructor & Destructor Documentation

◆ __construct()

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

Initialize dependencies.

Parameters
WebapiCache$cache
Reader$configReader
SerializerInterface | null$serializer

Definition at line 58 of file Config.php.

62  {
63  $this->cache = $cache;
64  $this->configReader = $configReader;
65  $this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
66  }

Member Function Documentation

◆ getServices()

getServices ( )

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

Returns
array
Since
100.2.4
}

Implements ConfigInterface.

Definition at line 71 of file Config.php.

72  {
73  if (null === $this->services) {
74  $services = $this->cache->load(self::CACHE_ID);
75  if ($services && is_string($services)) {
76  $this->services = $this->serializer->unserialize($services);
77  } else {
78  $this->services = $this->configReader->read();
79  $this->cache->save($this->serializer->serialize($this->services), self::CACHE_ID);
80  }
81  }
82  return $this->services;
83  }

Field Documentation

◆ $cache

$cache
protected

Definition at line 34 of file Config.php.

◆ $configReader

$configReader
protected

Definition at line 39 of file Config.php.

◆ $services

$services
protected

Definition at line 44 of file Config.php.

◆ API_PATTERN

const API_PATTERN = '/^(.+?)\\\\(.+?)\\\\Api(\\\\.+)Interface$/'

Definition at line 29 of file Config.php.

◆ CACHE_ID

const CACHE_ID = 'webapi_config'

Definition at line 22 of file Config.php.

◆ SERVICE_CLASS_PATTERN

const SERVICE_CLASS_PATTERN = '/^(.+?)\\\\(.+?)\\\\Service\\\\(V\d+)+(\\\\.+)Interface$/'

Pattern for Web API interface name.

Definition at line 27 of file Config.php.


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