forked from kaltura/server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntegrationProviderPlugin.php
82 lines (72 loc) · 2.23 KB
/
IntegrationProviderPlugin.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
<?php
/**
* @package plugins.integration
*/
abstract class IntegrationProviderPlugin extends KalturaPlugin implements IIntegrationProviderPlugin, IKalturaEnumerator, IKalturaPending, IKalturaObjectLoader
{
const INTEGRATION_PLUGIN_NAME = 'integration';
//exteding classes should implement this function to make sure
//there will be an object implementing IIntegrationProvider interface
abstract function getProvider();
/* (non-PHPdoc)
* @see IKalturaPending::dependsOn()
*/
public static function dependsOn()
{
$class = get_called_class();
$integrationVersion = $class::getRequiredIntegrationPluginVersion();
$dependency = new KalturaDependency(IntegrationPlugin::getPluginName(), $integrationVersion);
return array($dependency);
}
/* (non-PHPdoc)
* @see IKalturaEnumerator::getEnums()
*/
public static function getEnums($baseEnumName = null)
{
$class = get_called_class();
$integrationProviderClassName = $class::getIntegrationProviderClassName();
if(is_null($baseEnumName))
return array($integrationProviderClassName);
if($baseEnumName == 'IntegrationProviderType')
return array($integrationProviderClassName);
return array();
}
/* (non-PHPdoc)
* @see IKalturaObjectLoader::loadObject()
*/
public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
{
$class = get_called_class();
$objectClass = $class::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();
}
}
/**
* @return int id of dynamic enum in the DB.
*/
public static function getIntegrationProviderCoreValue($valueName)
{
$class = get_called_class();
$value = $class::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $valueName;
return kPluginableEnumsManager::apiToCore('IntegrationProviderType', $value);
}
/**
* @return string external API value of dynamic enum.
*/
public static function getApiValue($valueName)
{
$class = get_called_class();
return $class::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $valueName;
}
}