forked from kaltura/server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntegrationPlugin.php
145 lines (129 loc) · 3.42 KB
/
IntegrationPlugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* @package plugins.integration
*/
class IntegrationPlugin extends KalturaPlugin implements IKalturaPermissions, IKalturaServices, IKalturaEventConsumers, IKalturaEnumerator, IKalturaVersion, IKalturaPending, IKalturaObjectLoader
{
const PLUGIN_NAME = 'integration';
const PLUGIN_VERSION_MAJOR = 1;
const PLUGIN_VERSION_MINOR = 0;
const PLUGIN_VERSION_BUILD = 0;
const INTEGRATION_FLOW_MANAGER = 'kIntegrationFlowManager';
/* (non-PHPdoc)
* @see IKalturaPlugin::getPluginName()
*/
public static function getPluginName()
{
return self::PLUGIN_NAME;
}
/* (non-PHPdoc)
* @see IKalturaPending::dependsOn()
*/
public static function dependsOn()
{
$dependency = new KalturaDependency(MetadataPlugin::getPluginName());
return array($dependency);
}
/* (non-PHPdoc)
* @see IKalturaPermissions::isAllowedPartner()
*/
public static function isAllowedPartner($partnerId)
{
$partner = PartnerPeer::retrieveByPK($partnerId);
if(!$partner)
return false;
return $partner->getPluginEnabled(self::PLUGIN_NAME);
}
/* (non-PHPdoc)
* @see IKalturaServices::getServicesMap()
*/
public static function getServicesMap()
{
$map = array(
'integration' => 'IntegrationService',
);
return $map;
}
/* (non-PHPdoc)
* @see IKalturaEventConsumers::getEventConsumers()
*/
public static function getEventConsumers()
{
return array(
self::INTEGRATION_FLOW_MANAGER,
);
}
/* (non-PHPdoc)
* @see IKalturaEnumerator::getEnums()
*/
public static function getEnums($baseEnumName = null)
{
if(is_null($baseEnumName))
return array('IntegrationBatchJobType');
if($baseEnumName == 'BatchJobType')
return array('IntegrationBatchJobType');
return array();
}
/* (non-PHPdoc)
* @see IKalturaVersion::getVersion()
*/
public static function getVersion()
{
return new KalturaVersion(
self::PLUGIN_VERSION_MAJOR,
self::PLUGIN_VERSION_MINOR,
self::PLUGIN_VERSION_BUILD
);
}
/* (non-PHPdoc)
* @see IKalturaObjectLoader::loadObject()
*/
public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
{
$objectClass = self::getObjectClass($baseClass, $enumValue);
if (is_null($objectClass))
{
return null;
}
if (!is_null($constructorArgs))
{
$reflect = new ReflectionClass($objectClass);
return $reflect->newInstanceArgs($constructorArgs);
}
else
{
return new $objectClass();
}
}
/* (non-PHPdoc)
* @see IKalturaObjectLoader::getObjectClass()
*/
public static function getObjectClass($baseClass, $enumValue)
{
if($baseClass == 'kJobData')
{
if($enumValue == self::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION))
return 'kIntegrationJobData';
}
if($baseClass == 'KalturaJobData')
{
if($enumValue == self::getApiValue(IntegrationBatchJobType::INTEGRATION) || $enumValue == self::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION))
return 'KalturaIntegrationJobData';
}
}
/**
* @return int id of dynamic enum in the DB.
*/
public static function getBatchJobTypeCoreValue($valueName)
{
$value = self::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $valueName;
return kPluginableEnumsManager::apiToCore('BatchJobType', $value);
}
/**
* @return string external API value of dynamic enum.
*/
public static function getApiValue($valueName)
{
return self::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $valueName;
}
}