Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
servicepool.php
1<?php
2
4
8
9final class ServicePool
10{
11 private static function buildService($type, $clientId, $serviceType) : ?ServiceWrapper
12 {
13 if (is_string($type) && $clientId && is_string($serviceType))
14 {
17 ->setType($type)
18 ->setEngineCode($serviceType)
19 ->setClientId($clientId)
20 ->setService(ServiceFactory::getServiceByEngineCode($serviceType))
21 );
22 }
23 return null;
24 }
25
33 public static function getService($type) : ?ServiceWrapper
34 {
35 $types = (is_array($type)? $type : [$type]);
36 foreach ($types as $type)
37 {
38 while ($data = ServiceQueue::getInstance($type)->getHead())
39 {
40 try
41 {
42 $wrapper = static::buildService($data['TYPE'],$data['CLIENT_ID'],$data['SERVICE_TYPE']);
43 }
44 finally
45 {
46 if ($wrapper && $wrapper::getAuthAdapter($type)->hasAuth())
47 {
48 return $wrapper;
49 }
50 ServiceQueue::getInstance($type)->removeHead();
51 }
52 }
53 }
54 return null;
55 }
56
57}
setMeta(?ServiceMetaData $metaData)
static getServiceByEngineCode(string $engineCode)