Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
servicefactory.php
1<?php
2
4
5use Bitrix\Seo;
7
8final class ServiceFactory
9{
11 private static $enginePool;
12
16 private static function getServices() : array
17 {
18 return [
19 Seo\BusinessSuite\Service::getInstance(),
20 Seo\LeadAds\Service::getInstance(),
21 Seo\Analytics\Service::getInstance(),
22 Seo\Retargeting\Service::getInstance(),
23 Seo\Marketing\Service::getInstance(),
24 Seo\Catalog\Service::getInstance()
25 ];
26 }
27
31 private static function getEnginePool() : array
32 {
33 if(!static::$enginePool)
34 {
35 static::$enginePool = [];
36 foreach (self::getServices() as $service)
37 {
38 foreach ($service::getTypes() as $type)
39 {
40 static::$enginePool[$service::getEngineCode($type)] = $service;
41 }
42 }
43 }
44 return static::$enginePool;
45 }
46
54 public static function getServiceByEngineCode(string $engineCode) : Seo\BusinessSuite\IInternalService
55 {
56 if(array_key_exists($engineCode,$pool = static::getEnginePool()))
57 {
58 return $pool[$engineCode];
59 }
60 throw new Exception\ServiceLoadException('EngineCode');
61 }
62}
static getServiceByEngineCode(string $engineCode)