Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
factorybuilder.php
1
<?php
2
3
namespace
Bitrix\Calendar\Sync\Factories
;
4
5
use
Bitrix\Calendar\Core\Base\BaseException
;
6
use
Bitrix\Calendar\Core\Builders\Builder
;
7
use
Bitrix\Calendar\Sync
;
8
9
class
FactoryBuilder
implements
Builder
10
{
14
private
FactoryBase
$factory;
15
24
public
static
function
create
(
25
string
$accountType,
26
Sync\
Connection
\
Connection
$connection,
27
Sync\
Util
\
Context
$context
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,
44
Sync\
Connection
\
Connection
$connection,
45
Sync\
Util
\
Context
$context
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
}
Bitrix\Calendar\Core\Base\BaseException
Definition
baseexception.php:8
Bitrix\Calendar\Core\Mappers\Connection
Definition
connection.php:23
Bitrix\Calendar\Rooms\Util
Definition
util.php:20
Bitrix\Calendar\Sync\Factories\FactoryBase
Definition
factorybase.php:12
Bitrix\Calendar\Sync\Factories\FactoryBuilder
Definition
factorybuilder.php:10
Bitrix\Calendar\Sync\Factories\FactoryBuilder\build
build()
Definition
factorybuilder.php:89
Bitrix\Calendar\Sync\Factories\FactoryBuilder\getClassName
static getClassName(string $accountType)
Definition
factorybuilder.php:81
Bitrix\Calendar\Sync\Factories\FactoryBuilder\checkService
static checkService($serviceName)
Definition
factorybuilder.php:98
Bitrix\Calendar\Sync\Factories\FactoryBuilder\__construct
__construct(string $accountType, Sync\Connection\Connection $connection, Sync\Util\Context $context)
Definition
factorybuilder.php:42
Bitrix\Calendar\Sync\Factories\FactoryBuilder\create
static create(string $accountType, Sync\Connection\Connection $connection, Sync\Util\Context $context)
Definition
factorybuilder.php:24
Bitrix\Calendar\Sync\Factories\FactoryBuilder\getAvailableServices
static getAvailableServices(string $parentService)
Definition
factorybuilder.php:60
Bitrix\Calendar\Sync\Util\Context
Definition
context.php:18
Bitrix\Calendar\Core\Builders\Builder
Definition
builder.php:6
Bitrix\Calendar\Sync\Factories
Definition
eventconnectionfactory.php:3
Bitrix\Calendar\Sync
modules
calendar
lib
sync
factories
factorybuilder.php
Создано системой
1.10.0