Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
manager.php
1<?php
2
4
6
7class Manager
8{
9 public const SCHEDULER_SERVICE_NAME = 'schedulerService';
10 public const STATE_SERVICE_NAME = 'stateService';
11 public const TRACKING_SERVICE_NAME = 'trackingService';
12 public const TASK_SERVICE_NAME = 'taskService';
13 public const HISTORY_SERVICE_NAME = 'historyService';
14 public const DOCUMENT_SERVICE_NAME = 'documentService';
15 public const ANALYTICS_SERVICE_NAME = 'analyticsService';
16 public const USER_SERVICE_NAME = 'userService';
17
19 private $serviceLocator;
20
21 private function __construct()
22 {
23 $this->serviceLocator = ServiceLocator::getInstance();
24 }
25
26 public static function getInstance(): self
27 {
28 return new static();
29 }
30
31 public function getService(string $serviceName)
32 {
33 return $this->serviceLocator->get($this->getFullServiceName($serviceName));
34 }
35
36 public function hasDebugService(string $serviceName): bool
37 {
38 return $this->serviceLocator->has($this->getFullServiceName($serviceName, true));
39 }
40
41 public function getDebugService(string $serviceName)
42 {
43 return $this->serviceLocator->get($this->getFullServiceName($serviceName, true));
44 }
45
49 public function getAllServiceNames(): array
50 {
51 return [
52 static::SCHEDULER_SERVICE_NAME,
53 static::STATE_SERVICE_NAME,
54 static::TRACKING_SERVICE_NAME,
55 static::TASK_SERVICE_NAME,
56 static::HISTORY_SERVICE_NAME,
57 static::DOCUMENT_SERVICE_NAME,
58 static::ANALYTICS_SERVICE_NAME,
59 static::USER_SERVICE_NAME,
60 ];
61 }
62
63 public function getAllServices(): array
64 {
65 $services = [];
66
67 foreach ($this->getAllServiceNames() as $serviceName)
68 {
69 $services[$serviceName] = $this->serviceLocator->get($this->getFullServiceName($serviceName));
70 }
71
72 return $services;
73 }
74
75 public function getAllDebugServices(): array
76 {
77 $services = [];
78
79 foreach ($this->getAllServiceNames() as $serviceName)
80 {
81 $fullServiceName = $this->getFullServiceName($serviceName, true);
82
83 if ($this->serviceLocator->has($fullServiceName))
84 {
85 $services[$serviceName] = $this->serviceLocator->get($fullServiceName);
86 }
87 }
88
89 return $services;
90 }
91
92 private function getFullServiceName(string $serviceName, bool $isDebugService = false): string
93 {
94 if ($isDebugService)
95 {
96 return "bizproc.debugger.service.{$serviceName}";
97 }
98
99 return "bizproc.service.{$serviceName}";
100 }
101}
getService(string $serviceName)
Definition manager.php:31
getDebugService(string $serviceName)
Definition manager.php:41
hasDebugService(string $serviceName)
Definition manager.php:36