1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
factorybuilder.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Sync\Factories;
4
5use Bitrix\Calendar\Core\Base\BaseException;
6use Bitrix\Calendar\Core\Builders\Builder;
7use Bitrix\Calendar\Sync;
8
9class FactoryBuilder implements Builder
10{
14 private FactoryBase $factory;
15
24 public static function create(
25 string $accountType,
28 ): ?FactoryBase
29 {
30 return self::getClassName($accountType)
31 ? (new self($accountType, $connection, $context))->build()
32 : null;
33 }
34
42 public function __construct(
43 string $accountType,
46 )
47 {
48 $className = self::getClassName($accountType);
49 if (!$className)
50 {
51 throw new BaseException('Factory for accout type is not found');
52 }
53 $this->factory = new $className($connection, $context);
54 }
55
60 public static function getAvailableServices(string $parentService): array
61 {
62 return array_diff(array_keys(self::getServiceMap()), [$parentService]);
63 }
64
68 private static function getServiceMap(): array
69 {
70 return [
71 Sync\Google\Factory::SERVICE_NAME => Sync\Google\Factory::class,
72 Sync\Office365\Factory::SERVICE_NAME => Sync\Office365\Factory::class,
73 Sync\Icloud\Factory::SERVICE_NAME => Sync\Icloud\Factory::class,
74 ];
75 }
76
81 public static function getClassName(string $accountType): ?string
82 {
83 return self::getServiceMap()[$accountType] ?? null;
84 }
85
89 public function build(): FactoryBase
90 {
91 return $this->factory;
92 }
93
98 public static function checkService($serviceName): bool
99 {
100 return array_key_exists($serviceName, self::getServiceMap());
101 }
102}
$connection
Определения actionsdefinitions.php:38
static getClassName(string $accountType)
Определения factorybuilder.php:81
static checkService($serviceName)
Определения factorybuilder.php:98
__construct(string $accountType, Sync\Connection\Connection $connection, Sync\Util\Context $context)
Определения factorybuilder.php:42
static create(string $accountType, Sync\Connection\Connection $connection, Sync\Util\Context $context)
Определения factorybuilder.php:24
static getAvailableServices(string $parentService)
Определения factorybuilder.php:60
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$context
Определения csv_new_setup.php:223
Определения culture.php:9