Пример #1
0
 /**
  * 
  * Allow plugin to set additional information on ConvertJobData object
  * 
  * @param string $conversionEngineId
  * @param kConvertJobData $convertData
  */
 private static function contributeToConvertJobData($conversionEngineId, kConvertJobData &$convertData)
 {
     $plugin = kPluginableEnumsManager::getPlugin($conversionEngineId);
     if ($plugin && $plugin instanceof IKalturaBatchJobDataContributor) {
         KalturaLog::log("Setting additional data by plugin");
         $convertData = $plugin->contributeToConvertJobData(BatchJobType::CONVERT, $conversionEngineId, $convertData);
     }
 }
    /**
     * @param KalturaSchemaType $type  
     * @return string filePath 
     */
    public static function getSchemaPath($type)
    {
        $cacheXsdFile = kConf::get("cache_root_path") . "/{$type}.xsd";
        if (file_exists($cacheXsdFile)) {
            return realpath($cacheXsdFile);
        }
        $xsdFile = fopen($cacheXsdFile, 'w');
        $elementsXSD = '';
        $baseXsdElement = new SimpleXMLElement('<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"/>');
        if ($type == SchemaType::SYNDICATION) {
            $baseXsdElement = new SimpleXMLElement(file_get_contents(kConf::get("syndication_core_xsd_path")));
        } else {
            $plugin = kPluginableEnumsManager::getPlugin($type);
            if ($plugin instanceof IKalturaSchemaDefiner) {
                KalturaLog::debug("Found plugin [" . get_class($plugin) . "]");
                $baseXsdElement = $plugin->getPluginSchema($type);
            }
        }
        if (!$baseXsdElement instanceof SimpleXMLElement) {
            $baseXsdElement = new SimpleXMLElement('<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"/>');
        }
        $version = '1.0';
        if ($baseXsdElement['version']) {
            $version = $baseXsdElement['version'];
        }
        fwrite($xsdFile, "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" version=\"{$version}\">");
        foreach ($baseXsdElement->children('http://www.w3.org/2001/XMLSchema') as $element) {
            /* @var $element SimpleXMLElement */
            $xsd = $element->asXML();
            $elementsXSD .= $xsd;
            fwrite($xsdFile, '
	' . $xsd);
        }
        $schemaContributors = KalturaPluginManager::getPluginInstances('IKalturaSchemaContributor');
        foreach ($schemaContributors as $key => $schemaContributor) {
            /* @var $schemaContributor IKalturaSchemaContributor */
            $elements = $schemaContributor->contributeToSchema($type);
            if ($elements) {
                $elementsXSD .= $elements;
                fwrite($xsdFile, $elements);
            }
        }
        fwrite($xsdFile, '
	<!-- Kaltura enum types -->
	');
        $enumClasses = array();
        $matches = null;
        if (preg_match_all('/type="(Kaltura[^"]+)"/', $elementsXSD, $matches)) {
            $enumClasses = $matches[1];
        }
        $enumTypes = array();
        foreach ($enumClasses as $class) {
            $classTypeReflector = KalturaTypeReflectorCacher::get($class);
            if ($classTypeReflector) {
                self::loadClassRecursively($classTypeReflector, $enumTypes);
            }
        }
        foreach ($enumTypes as $class => $classTypeReflector) {
            if (!is_subclass_of($class, 'KalturaEnum') && !is_subclass_of($class, 'KalturaStringEnum')) {
                // class must be enum
                continue;
            }
            $xsdType = 'int';
            if ($classTypeReflector->isStringEnum()) {
                $xsdType = 'string';
            }
            $xsd = '
	<xs:simpleType name="' . $class . '">
		<xs:annotation><xs:documentation>http://' . kConf::get('www_host') . '/api_v3/testmeDoc/index.php?object=' . $class . '</xs:documentation></xs:annotation>
		<xs:restriction base="xs:' . $xsdType . '">';
            $contants = $classTypeReflector->getConstants();
            foreach ($contants as $contant) {
                $xsd .= '
			<xs:enumeration value="' . $contant->getDefaultValue() . '"><xs:annotation><xs:documentation>' . $contant->getName() . '</xs:documentation></xs:annotation></xs:enumeration>';
            }
            $xsd .= '
		</xs:restriction>
	</xs:simpleType>
			';
            fwrite($xsdFile, $xsd);
        }
        fwrite($xsdFile, '
</xs:schema>');
        fclose($xsdFile);
        return realpath($cacheXsdFile);
    }
Пример #3
0
 /**
  * @param entry $entry
  * @return array
  */
 private static function getCuePointTypeToClone($entry)
 {
     $listOfEnumIds = array();
     $cue_point_plugin_map = kPluginableEnumsManager::getCoreMap('CuePointType');
     foreach ($cue_point_plugin_map as $dynamic_enum_id => $plugin_name) {
         $plugin = kPluginableEnumsManager::getPlugin($plugin_name);
         if ($plugin::shouldCloneByProperty($entry) == true) {
             $listOfEnumIds[] = $dynamic_enum_id;
         }
     }
     return $listOfEnumIds;
 }