7 declare(strict_types=1);
21 const CACHE_ID =
'webapi_bulk_async_service_config';
30 private $webapiConfig;
53 $this->webapiConfig = $webapiConfig;
64 if (
null === $this->services) {
65 $services = $this->cache->load(self::CACHE_ID);
66 if ($services && is_string($services)) {
67 $this->services = $this->serializer->unserialize($services);
69 $this->services = $this->getBulkServicesConfig();
70 $this->cache->save($this->serializer->serialize($this->services),
self::CACHE_ID);
74 return $this->services;
80 private function getBulkServicesConfig()
83 $webapiServices = $this->webapiConfig->getServices();
84 foreach ($webapiServices[WebapiConverter::KEY_ROUTES] as $routePath => $routeConfig) {
85 foreach ($routeConfig as $httpMethod => $httpMethodConfig) {
86 if ($httpMethod !== \
Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET) {
87 $routePath = preg_replace_callback(
90 return '/' . self::URL_PARAM_PREFIX_PLACEHOLDER . ucfirst($matches[1]);
94 $bulkServices[WebapiConverter::KEY_ROUTES][$routePath][$httpMethod] = $httpMethodConfig;
98 $bulkServices[WebapiConverter::KEY_SERVICES] = $webapiServices[WebapiConverter::KEY_SERVICES];
100 return $bulkServices;
__construct(WebapiCache $cache, Config $webapiConfig, SerializerInterface $serializer)
const URL_PARAM_PREFIX_PLACEHOLDER