function serializeObject($object)
 {
     if ($object instanceof Exception) {
         $this->writeStartTag("error");
         $this->writeTag("code", $object->getCode());
         $this->writeTag("message", $object->getMessage());
         $this->writeEndTag("error");
     } else {
         // get object class
         $reflectObject = new ReflectionObject($object);
         $class = $reflectObject->getName();
         // load class reflection
         $typeReflector = KalturaTypeReflectorCacher::get($class);
         $properties = $typeReflector->getProperties();
         // write the object type
         $this->writeTag("objectType", $class);
         foreach ($properties as $property) {
             $name = $property->getName();
             $value = $object->{$name};
             if ($this->_ignoreNull === true && $value === null) {
                 continue;
             }
             $this->writeStartTag($name);
             $this->serialize($value);
             $this->writeEndTag($name);
         }
     }
 }
 private function handleSingleSearchObjectFile($key)
 {
     /** @var IndexableObject $object */
     $object = $this->searchableObjects[$key];
     if (!$object->apiName) {
         return;
     }
     $typeReflector = KalturaTypeReflectorCacher::get($object->apiName);
     $apiTypes = array_merge(array($object->apiName), $typeReflector->getSubTypesNames());
     $classesToGenerate = array();
     foreach ($apiTypes as $apiType) {
         $classesToGenerate[$apiType . 'MatchAttributeCondition'] = array($apiType, $apiType . 'MatchAttribute', 'KalturaSearchMatchAttributeCondition');
         $classesToGenerate[$apiType . 'CompareAttributeCondition'] = array($apiType, $apiType . 'CompareAttribute', 'KalturaSearchComparableAttributeCondition');
     }
     foreach ($classesToGenerate as $className => $additionalData) {
         $apiObjectClass = $additionalData[0];
         $enumType = $additionalData[1];
         $parentClass = $additionalData[2];
         $filePath = $this->getFilePathForSearchObject($apiObjectClass, $className);
         if (!file_exists(dirname($filePath))) {
             mkdir(dirname($filePath), 0777, true);
         }
         $fp = fopen($filePath, 'w+');
         if (!$fp) {
             KalturaLog::err("Failed to open file " . $filePath);
             exit(1);
         }
         print "\tGenerating API object {$className}\n";
         $this->createClassFileHeader($fp, $className, $parentClass, $apiObjectClass, $enumType);
         $this->generateClass($fp, $className, $enumType, $key . 'Index');
         $this->createClassFileFooter($fp, $className);
         fclose($fp);
     }
 }
 function serializeObject($object)
 {
     if ($object instanceof Exception) {
         echo '<error>';
         $this->writeTag('code', $object->getCode());
         $this->writeTag('message', $object->getMessage());
         echo '</error>';
     } else {
         // get object class
         $reflectObject = new ReflectionObject($object);
         $class = $reflectObject->getName();
         // write the object type
         $this->writeTag('objectType', $class);
         // load class reflection
         $typeReflector = KalturaTypeReflectorCacher::get($class);
         if (!$typeReflector) {
             echo '<error>';
             $this->writeTag('message', 'Type reflector not found');
             echo '</error>';
             return;
         }
         $properties = $typeReflector->getProperties();
         foreach ($properties as $property) {
             $name = $property->getName();
             $value = $object->{$name};
             if ($this->_ignoreNull === true && $value === null) {
                 continue;
             }
             echo '<' . $name . '>';
             $this->serialize($value);
             echo '</' . $name . '>';
         }
     }
 }
Example #4
0
 public function getArrayTypeReflector()
 {
     if ($this->_arrayTypeReflector === null) {
         if (!$this->isSimpleType()) {
             $this->_arrayTypeReflector = KalturaTypeReflectorCacher::get($this->getArrayType());
         }
     }
     return $this->_arrayTypeReflector;
 }
 /**
  * @param Partner $partner
  * @return KalturaSystemPartnerLimitArray
  */
 public static function fromPartner(Partner $partner)
 {
     $arr = new KalturaSystemPartnerLimitArray();
     $reflector = KalturaTypeReflectorCacher::get('KalturaSystemPartnerLimitType');
     $types = $reflector->getConstants();
     foreach ($types as $typeInfo) {
         $typeValue = $typeInfo->getDefaultValue();
         $arr[] = KalturaSystemPartnerOveragedLimit::fromPartner($typeValue, $partner);
     }
     return $arr;
 }
 public function fromObject($source_object)
 {
     $ret = parent::fromObject($source_object);
     $languageReflector = KalturaTypeReflectorCacher::get('KalturaLanguage');
     $languageCodeReflector = KalturaTypeReflectorCacher::get('KalturaLanguageCode');
     if ($languageReflector && $languageCodeReflector) {
         $languageCode = $languageReflector->getConstantName($this->language);
         if ($languageCode) {
             $this->languageCode = $languageCodeReflector->getConstantValue($languageCode);
         }
     }
     return $ret;
 }
Example #7
0
 public function doFromObject($source_object, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $ret = parent::doFromObject($source_object, $responseProfile);
     if ($this->shouldGet('languageCode', $responseProfile)) {
         $languageReflector = KalturaTypeReflectorCacher::get('KalturaLanguage');
         $languageCodeReflector = KalturaTypeReflectorCacher::get('KalturaLanguageCode');
         if ($languageReflector && $languageCodeReflector) {
             $languageCode = $languageReflector->getConstantName($this->language);
             if ($languageCode) {
                 $this->languageCode = $languageCodeReflector->getConstantValue($languageCode);
             }
         }
     }
     return $ret;
 }
 public function appendCaptionElement($tag, $fileExt, $language)
 {
     $languageReflector = KalturaTypeReflectorCacher::get('KalturaLanguage');
     $captionElem = $this->_doc->createElement('caption');
     $captionElem->setAttribute('tag', $tag);
     $captionElem->appendChild($this->_doc->createElement('format', $fileExt));
     $captionElem->appendChild($this->_doc->createElement('language', $languageReflector->getConstantName($language)));
     $this->_doc->firstChild->appendChild($captionElem);
     return $captionElem;
 }
 static function enable()
 {
     self::$_enabled = true;
 }
Example #10
0
 public function validateForUsage($sourceObject, $propertiesToSkip = array())
 {
     $useableProperties = array();
     $reflector = KalturaTypeReflectorCacher::get(get_class($this));
     if (!$reflector) {
         KalturaLog::err("Unable to validate usage for attribute object type [" . get_class($this) . "], type reflector not found");
         throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_USAGE_PERMISSION, get_class($this));
     }
     $properties = $reflector->getProperties();
     if ($reflector->requiresUsagePermission() && !kPermissionManager::getUsagePermitted(get_class($this), kApiParameterPermissionItem::ALL_VALUES_IDENTIFIER)) {
         throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_USAGE_PERMISSION, get_class($this));
     }
     foreach ($properties as $property) {
         /* @var $property KalturaPropertyInfo */
         $propertyName = $property->getName();
         if ($propertiesToSkip && is_array($propertiesToSkip) && in_array($propertyName, $propertiesToSkip)) {
             continue;
         }
         if ($this->{$propertyName} !== null) {
             // check if property value is being changed - if not, just continue to the next
             $objectPropertyName = $this->getObjectPropertyName($propertyName);
             $getter_callback = array($sourceObject, "get{$objectPropertyName}");
             if (is_callable($getter_callback)) {
                 $value = call_user_func($getter_callback);
                 if ($value === $this->{$propertyName} || is_bool($this->{$propertyName}) && $value === (int) $this->{$propertyName}) {
                     continue;
                 }
             }
             // property requires update permissions, verify that the current user has it
             if ($property->requiresUsagePermission()) {
                 if (!kPermissionManager::getUsagePermitted($this->getDeclaringClassName($propertyName), $propertyName)) {
                     //throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_UPDATE_PERMISSION, $this->getFormattedPropertyNameWithClassName($propertyName));
                     //TODO: not throwing exception to not break clients that sends -1 as null for integer values (etc...)
                     $e = new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_USAGE_PERMISSION, $this->getFormattedPropertyNameWithClassName($propertyName));
                     $this->{$propertyName} = null;
                     KalturaLog::err($this->getDeclaringClassName($propertyName) . '-' . $propertyName . ' error: ' . $e->getMessage());
                     header($this->getDeclaringClassName($propertyName) . '-' . $propertyName . ' error: ' . $e->getMessage());
                 }
             }
         }
     }
     return $useableProperties;
 }
 private function buildObject(KalturaTypeReflector $typeReflector, array &$params)
 {
     // if objectType was specified, we will use it only if the anotation type is it's base type
     if (array_key_exists("objectType", $params)) {
         $possibleType = $params["objectType"];
         if (strtolower($possibleType) !== strtolower($typeReflector->getType())) {
             if ($typeReflector->isParentOf($possibleType)) {
                 // we know that the objectType that came from the user is right, and we can use it to initiate the object
                 $typeReflector = KalturaTypeReflectorCacher::get($possibleType);
             }
         }
     }
     $class = $typeReflector->getType();
     $obj = new $class();
     $properties = $typeReflector->getProperties();
     foreach ($properties as $property) {
         $name = $property->getName();
         $type = $property->getType();
         if ($property->isSimpleType() || $property->isEnum() || $property->isStringEnum()) {
             if (!array_key_exists($name, $params)) {
                 // missing parameters should be null or default propery value
                 continue;
             }
             $value = $params[$name];
             if ($property->isSimpleType()) {
                 $obj->{$name} = $this->castSimpleType($type, $value);
             } else {
                 if ($property->isEnum()) {
                     if (!$property->getTypeReflector()->checkEnumValue($value)) {
                         throw new KalturaAPIException(KalturaErrors::INVALID_ENUM_VALUE, $value, $name, $property->getType());
                     }
                     $obj->{$name} = $this->castSimpleType("int", $value);
                 } else {
                     if ($property->isStringEnum()) {
                         if (!$property->getTypeReflector()->checkStringEnumValue($value)) {
                             throw new KalturaAPIException(KalturaErrors::INVALID_ENUM_VALUE, $value, $name, $property->getType());
                         }
                         $obj->{$name} = $this->castSimpleType("string", $value);
                     }
                 }
             }
         } else {
             if ($property->isArray()) {
                 if (isset($params[$name]) && is_array($params[$name])) {
                     $arrayObj = new $type();
                     foreach ($params[$name] as $arrayItemParams) {
                         $arrayObj[] = $this->buildObject($property->getArrayTypeReflector(), $arrayItemParams);
                     }
                     $obj->{$name} = $arrayObj;
                 }
             } else {
                 if ($property->isComplexType()) {
                     if (isset($params[$name]) && is_array($params[$name])) {
                         $obj->{$name} = $this->buildObject($property->getTypeReflector(), $params[$name]);
                     }
                 }
             }
         }
     }
     return $obj;
 }
 private function buildObject(KalturaTypeReflector $typeReflector, array &$params, $objectName)
 {
     // if objectType was specified, we will use it only if the anotation type is it's base type
     if (array_key_exists("objectType", $params)) {
         $possibleType = $params["objectType"];
         if (strtolower($possibleType) !== strtolower($typeReflector->getType())) {
             if ($typeReflector->isParentOf($possibleType)) {
                 $newTypeReflector = KalturaTypeReflectorCacher::get($possibleType);
                 if ($newTypeReflector) {
                     $typeReflector = $newTypeReflector;
                 }
             }
         }
     }
     if ($typeReflector->isAbstract()) {
         throw new KalturaAPIException(KalturaErrors::OBJECT_TYPE_ABSTRACT, $typeReflector->getType());
     }
     $class = $typeReflector->getType();
     $obj = new $class();
     $properties = $typeReflector->getProperties();
     foreach ($params as $name => $value) {
         $isNull = false;
         if (kString::endsWith($name, '__null')) {
             $name = str_replace('__null', '', $name);
             $isNull = true;
         }
         if (!array_key_exists($name, $properties)) {
             continue;
         }
         $property = $properties[$name];
         /* @var $property KalturaPropertyInfo */
         $type = $property->getType();
         if ($isNull && !$property->isArray()) {
             $obj->{$name} = new KalturaNullField();
             continue;
         }
         if ($property->isSimpleType()) {
             if ($property->isTime()) {
                 $type = "time";
             }
             $value = $this->castSimpleType($type, $value);
             if (!kXml::isXMLValidContent($value)) {
                 throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_CHAR, $name);
             }
             $this->validateParameter($name, $value, $property);
             $obj->{$name} = $value;
             continue;
         }
         if ($property->isEnum()) {
             if (strtolower($value) == 'true') {
                 $value = 1;
             }
             if (strtolower($value) == 'false') {
                 $value = 0;
             }
             if (!$property->getTypeReflector()->checkEnumValue($value)) {
                 throw new KalturaAPIException(KalturaErrors::INVALID_ENUM_VALUE, $value, $name, $property->getType());
             }
             if ($type == 'KalturaNullableBoolean') {
                 $obj->{$name} = KalturaNullableBoolean::toBoolean($value);
                 continue;
             }
             $obj->{$name} = $this->castSimpleType("int", $value);
             continue;
         }
         if ($property->isStringEnum()) {
             if (!$property->getTypeReflector()->checkStringEnumValue($value)) {
                 throw new KalturaAPIException(KalturaErrors::INVALID_ENUM_VALUE, $value, $name, $property->getType());
             }
             $value = $this->castSimpleType("string", $value);
             if (!kXml::isXMLValidContent($value)) {
                 throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_CHAR, $name);
             }
             $obj->{$name} = $value;
             continue;
         }
         if ($property->isArray() && is_array($value)) {
             $arrayObj = new $type();
             if ($property->isAssociativeArray()) {
                 foreach ($value as $arrayItemKey => $arrayItemParams) {
                     if ($arrayItemKey === '-') {
                         break;
                     }
                     $arrayObj[$arrayItemKey] = $this->buildObject($property->getArrayTypeReflector(), $arrayItemParams, "{$objectName}:{$name}");
                 }
             } else {
                 ksort($value);
                 foreach ($value as $arrayItemKey => $arrayItemParams) {
                     if ($arrayItemKey === '-') {
                         break;
                     }
                     $arrayObj[] = $this->buildObject($property->getArrayTypeReflector(), $arrayItemParams, "{$objectName}:{$name}");
                 }
             }
             $obj->{$name} = $arrayObj;
             continue;
         }
         if ($property->isComplexType() && is_array($value)) {
             $obj->{$name} = $this->buildObject($property->getTypeReflector(), $value, "{$objectName}:{$name}");
             continue;
         }
         if ($property->isFile()) {
             $obj->{$name} = $value;
             continue;
         }
     }
     return $obj;
 }
 private function getLanguageCode($language = null)
 {
     $languageReflector = KalturaTypeReflectorCacher::get('KalturaLanguage');
     $languageCodeReflector = KalturaTypeReflectorCacher::get('KalturaLanguageCode');
     if ($languageReflector && $languageCodeReflector) {
         $languageCode = $languageReflector->getConstantName($language);
         if ($languageCode) {
             return $languageCodeReflector->getConstantValue($languageCode);
         }
     }
     return null;
 }
Example #14
0
 public function setAdditionalList($list)
 {
     if ($list === null) {
         return;
     }
     $includeList = array();
     if (is_array($list)) {
         $includeList = $list;
     } else {
         $tempList = explode(",", str_replace(" ", "", $list));
         foreach ($tempList as $item) {
             if (class_exists($item)) {
                 $includeList[] = $item;
             }
         }
     }
     // Always add these two classes
     $includeList[] = 'KalturaApiExceptionArg';
     $includeList[] = 'KalturaClientConfiguration';
     $includeList[] = 'KalturaRequestConfiguration';
     foreach ($includeList as $class) {
         $classTypeReflector = KalturaTypeReflectorCacher::get($class);
         if ($classTypeReflector) {
             $this->loadTypesRecursive($classTypeReflector);
         }
     }
 }
Example #15
0
 public function validateForUpdate($source_object)
 {
     $updatableProperties = array();
     $reflector = KalturaTypeReflectorCacher::get(get_class($this));
     $properties = $reflector->getProperties();
     if ($reflector->requiresUpdatePermission() && !kPermissionManager::getUpdatePermitted(get_class($this), kApiParameterPermissionItem::ALL_VALUES_IDENTIFIER)) {
         throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_UPDATE_PERMISSION, get_class($this));
     }
     foreach ($properties as $property) {
         $propertyName = $property->getName();
         if ($this->{$propertyName} !== null) {
             // check if property value is being changed - if not, just continue to the next
             $objectPropertyName = $this->getObjectPropertyName($propertyName);
             $getter_callback = array($source_object, "get{$objectPropertyName}");
             if (is_callable($getter_callback)) {
                 $value = call_user_func($getter_callback);
                 if ($value === $this->{$propertyName}) {
                     continue;
                 }
             }
             if ($property->isReadOnly() || $property->isInsertOnly()) {
                 throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NOT_UPDATABLE, $this->getFormattedPropertyNameWithClassName($propertyName));
             }
             // property requires update permissions, verify that the current user has it
             if ($property->requiresUpdatePermission()) {
                 if (!kPermissionManager::getUpdatePermitted($this->getDeclaringClassName($propertyName), $propertyName)) {
                     //throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_UPDATE_PERMISSION, $this->getFormattedPropertyNameWithClassName($propertyName));
                     //TODO: not throwing exception to not break clients that sends -1 as null for integer values (etc...)
                     $e = new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_UPDATE_PERMISSION, $this->getFormattedPropertyNameWithClassName($propertyName));
                     $this->{$propertyName} = null;
                     header($this->getDeclaringClassName($propertyName) . '-' . $propertyName . ' error: ' . $e->getMessage());
                 }
             }
         }
     }
     return $updatableProperties;
 }
Example #16
0
 } else {
     $subTitle = 'Properties';
 }
 echo "<tr>\r\n\t\t\t<td colspan=\"4\" class=\"title\">\r\n\t\t\t\t{$subTitle}\r\n\t\t\t</td>\r\n\t\t</tr>";
 // property columns
 $columns = array('Name', 'Type');
 if ($typeReflector->isEnum() || $typeReflector->isStringEnum()) {
     $columns[] = 'Value';
 } elseif (!$typeReflector->getInstance() instanceof KalturaFilter) {
     $columns[] = 'Writable';
 }
 $columns[] = 'Description';
 // build baseClass->properties mapping
 $classProperties = array();
 foreach (getClassHierarchy($typeReflector->getType()) as $curClass) {
     $curReflector = KalturaTypeReflectorCacher::get($curClass);
     if ($typeReflector->isEnum() || $typeReflector->isStringEnum()) {
         $properties = $curReflector->getConstants();
     } else {
         $properties = $curReflector->getCurrentProperties();
     }
     if (count($properties) == 0) {
         continue;
     }
     usort($properties, 'comparePropNames');
     $classProperties[$curClass] = $properties;
 }
 $printClassHeaders = count($classProperties) > 1;
 foreach ($classProperties as $curClass => $properties) {
     echo "<tr>\r\n\t\t\t\t<td colspan=\"3\">";
     // print class header
Example #17
0
<?php

$config = new Zend_Config_Ini("../../config/testme.ini", null, array('allowModifications' => true));
$config = KalturaPluginManager::mergeConfigs($config, 'xsddoc', false);
$indexConfig = $config->get('xsddoc');
$exclude = explode(',', $indexConfig->get("exclude"));
$schemaReflector = KalturaTypeReflectorCacher::get('KalturaSchemaType');
$schemas = $schemaReflector->getConstants();
?>
<div class="left">
	<div class="left-content">
		<div id="general">
			<h2>General</h2>
			<ul>
				<li><a href="?page=overview">Overview</a></li>
			</ul>
		</div>

		<div id="schemas">
			<h2>Schemas</h2>
			<ul class="schemas">
			<?php 
foreach ($schemas as $schema) {
    ?>
				<li class="schema">
					<a href="?type=<?php 
    echo $schema->getDefaultValue();
    ?>
"><?php 
    echo $schema->getDescription();
    ?>
 public function fromObject($entry)
 {
     parent::fromObject($entry);
     $this->mediaDate = $entry->getMediaDate(null);
     $reflect = KalturaTypeReflectorCacher::get('KalturaSourceType');
     $constants = $reflect->getConstantsValues();
     $sourceApi = kPluginableEnumsManager::coreToApi('EntrySourceType', $entry->getSource());
     if (!in_array($sourceApi, $constants) || $sourceApi == EntrySourceType::SEARCH_PROVIDER) {
         $this->sourceType = KalturaSourceType::SEARCH_PROVIDER;
         $this->searchProviderType = $sourceApi;
     } else {
         $this->sourceType = $sourceApi;
         $this->searchProviderType = null;
     }
 }
 public function fromObject($object)
 {
     parent::fromObject($object);
     foreach (self::$actions as $action) {
         $actionAttribute = "{$action}Action";
         if (!$this->{$actionAttribute}) {
             $this->{$actionAttribute} = new KalturaGenericDistributionProfileAction();
         }
         $reflector = KalturaTypeReflectorCacher::get(get_class($this->{$actionAttribute}));
         $properties = $reflector->getProperties();
         foreach ($this->{$actionAttribute}->getMapBetweenObjects() as $this_prop => $object_prop) {
             if (is_numeric($this_prop)) {
                 $this_prop = $object_prop;
             }
             if (!isset($properties[$this_prop]) || $properties[$this_prop]->isWriteOnly()) {
                 continue;
             }
             $getter_callback = array($object, "get{$object_prop}");
             if (is_callable($getter_callback)) {
                 $value = call_user_func($getter_callback, $action);
                 if ($properties[$this_prop]->isDynamicEnum()) {
                     $propertyType = $properties[$this_prop]->getType();
                     $enumType = call_user_func(array($propertyType, 'getEnumClass'));
                     $value = kPluginableEnumsManager::coreToApi($enumType, $value);
                 }
                 $this->{$actionAttribute}->{$this_prop} = $value;
             } else {
                 KalturaLog::alert("getter for property [{$object_prop}] was not found on object class [" . get_class($object) . "]");
             }
         }
     }
     $this->updateRequiredEntryFields = implode(',', $object->getUpdateRequiredEntryFields());
     $this->updateRequiredMetadataXPaths = implode(',', $object->getUpdateRequiredMetadataXPaths());
 }
Example #20
0
 public function fromObject($source_object)
 {
     $reflector = KalturaTypeReflectorCacher::get(get_class($this));
     foreach ($this->getMapBetweenObjects() as $this_prop => $object_prop) {
         if (is_numeric($this_prop)) {
             $this_prop = $object_prop;
         }
         if (array_key_exists($object_prop, $source_object->fields)) {
             $value = $source_object->get($object_prop);
             $property = $reflector->getProperty($this_prop);
             if ($property->isDynamicEnum()) {
                 $propertyType = $property->getType();
                 $enumType = call_user_func(array($propertyType, 'getEnumClass'));
                 $value = kPluginableEnumsManager::coreToApi($enumType, $value);
             } elseif ($property->getDynamicType()) {
                 $propertyType = $property->getDynamicType();
                 $enumType = call_user_func(array($propertyType, 'getEnumClass'));
                 $values = explode(',', $value);
                 $finalValues = array();
                 foreach ($values as $val) {
                     $finalValues[] = kPluginableEnumsManager::coreToApi($enumType, $val);
                 }
                 $value = implode(',', $finalValues);
             }
             $this->{$this_prop} = $value;
         } else {
             KalturaLog::alert("field [{$object_prop}] was not found on filter object class [" . get_class($source_object) . "]");
         }
     }
     $newOrderBy = "";
     $orderByMap = $this->getOrderByMap();
     if ($orderByMap) {
         $orderProps = explode(",", $this->orderBy);
         foreach ($orderProps as $prop) {
             $key = array_search($prop, $orderByMap);
             if ($key !== false) {
                 $newOrderBy .= $key . ",";
             }
         }
     }
     if (strpos($newOrderBy, ",") === strlen($newOrderBy) - 1) {
         $newOrderBy = substr($newOrderBy, 0, strlen($newOrderBy) - 1);
     }
     $this->orderBy = $newOrderBy;
     $advancedSearch = $source_object->getAdvancedSearch();
     if (is_object($advancedSearch) && $advancedSearch instanceof AdvancedSearchFilterItem) {
         $apiClass = $advancedSearch->getKalturaClass();
         if (!class_exists($apiClass)) {
             KalturaLog::err("Class [{$apiClass}] not found");
         } else {
             $this->advancedSearch = new $apiClass();
             $this->advancedSearch->fromObject($advancedSearch);
         }
     } else {
         KalturaLog::debug("Advanced search not defined");
     }
 }
    /**
     * @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);
    }
 /**
  * Return a type reflector for the parent class (null if none) 
  *
  * @return KalturaTypeReflector
  */
 public function getParentTypeReflector()
 {
     if ($this->_type == 'KalturaObject') {
         return null;
     }
     $reflectClass = new ReflectionClass($this->_type);
     $parentClass = $reflectClass->getParentClass();
     if (!$parentClass) {
         throw new Exception("API object [{$this->_type}] must have parent type");
     }
     $parentClassName = $parentClass->getName();
     if (!in_array($parentClassName, array("KalturaObject", "KalturaEnum", "KalturaStringEnum", "KalturaTypedArray"))) {
         // from the api point of view, those objects are ignored
         return KalturaTypeReflectorCacher::get($parentClass->getName());
     } else {
         return null;
     }
 }
 private function buildObject(KalturaTypeReflector $typeReflector, array &$params, $objectName)
 {
     // if objectType was specified, we will use it only if the anotation type is it's base type
     if (array_key_exists("objectType", $params)) {
         $possibleType = $params["objectType"];
         if (strtolower($possibleType) !== strtolower($typeReflector->getType())) {
             if ($typeReflector->isParentOf($possibleType)) {
                 $newTypeReflector = KalturaTypeReflectorCacher::get($possibleType);
                 if ($newTypeReflector) {
                     $typeReflector = $newTypeReflector;
                 }
             }
         }
     }
     if ($typeReflector->isAbstract()) {
         throw new KalturaAPIException(KalturaErrors::OBJECT_TYPE_ABSTRACT, $typeReflector->getType());
     }
     $class = $typeReflector->getType();
     $obj = new $class();
     $properties = $typeReflector->getProperties();
     foreach ($properties as $property) {
         /* @var $property KalturaPropertyInfo */
         $name = $property->getName();
         $type = $property->getType();
         if ($property->isSimpleType() || $property->isEnum() || $property->isStringEnum()) {
             if (array_key_exists($name . '__null', $params)) {
                 $obj->{$name} = new KalturaNullField();
                 continue;
             }
             if (!array_key_exists($name, $params)) {
                 // missing parameters should be null or default propery value
                 continue;
             }
             $value = $params[$name];
             if ($property->isSimpleType()) {
                 $value = $this->castSimpleType($type, $value);
                 if (!kXml::isXMLValidContent($value)) {
                     throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_CHAR, $name);
                 }
                 $obj->{$name} = $value;
                 continue;
             }
             if ($property->isEnum()) {
                 if (!$property->getTypeReflector()->checkEnumValue($value)) {
                     throw new KalturaAPIException(KalturaErrors::INVALID_ENUM_VALUE, $value, $name, $property->getType());
                 }
                 if ($type == 'KalturaNullableBoolean') {
                     $obj->{$name} = KalturaNullableBoolean::toBoolean($value);
                     continue;
                 }
                 $obj->{$name} = $this->castSimpleType("int", $value);
                 continue;
             }
             if ($property->isStringEnum()) {
                 if (!$property->getTypeReflector()->checkStringEnumValue($value)) {
                     throw new KalturaAPIException(KalturaErrors::INVALID_ENUM_VALUE, $value, $name, $property->getType());
                 }
                 $value = $this->castSimpleType("string", $value);
                 if (!kXml::isXMLValidContent($value)) {
                     throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_CHAR, $name);
                 }
                 $obj->{$name} = $value;
                 continue;
             }
         }
         if ($property->isArray()) {
             if (isset($params[$name]) && is_array($params[$name])) {
                 ksort($params[$name]);
                 $arrayObj = new $type();
                 foreach ($params[$name] as $arrayItemParams) {
                     $arrayObj[] = $this->buildObject($property->getArrayTypeReflector(), $arrayItemParams, "{$objectName}:{$name}");
                 }
                 $obj->{$name} = $arrayObj;
             }
             continue;
         }
         if ($property->isComplexType()) {
             if (isset($params[$name]) && is_array($params[$name])) {
                 $obj->{$name} = $this->buildObject($property->getTypeReflector(), $params[$name], "{$objectName}:{$name}");
             }
             continue;
         }
         if ($property->isFile()) {
             if (isset($params[$name])) {
                 $obj->{$name} = $params[$name];
             }
             continue;
         }
     }
     return $obj;
 }
 public function setAdditionalList($list)
 {
     if ($list === null) {
         return;
     }
     $includeList = array();
     if (is_array($list)) {
         $includeList = $list;
     } else {
         $tempList = explode(",", str_replace(" ", "", $list));
         foreach ($tempList as $item) {
             if (class_exists($item)) {
                 $includeList[] = $item;
             }
         }
     }
     foreach ($includeList as $class) {
         $classTypeReflector = KalturaTypeReflectorCacher::get($class);
         if ($classTypeReflector) {
             $this->loadTypesRecursive($classTypeReflector);
         }
     }
 }