private function getClassElement(KalturaTypeReflector $typeReflector) { $properties = $typeReflector->getProperties(); $classElement = $this->_doc->createElement("class"); $classElement->setAttribute("name", $typeReflector->getType()); $parentTypeReflector = $typeReflector->getParentTypeReflector(); if ($typeReflector->isAbstract()) { $classElement->setAttribute("abstract", true); } if ($parentTypeReflector) { $parentType = $parentTypeReflector->getType(); $classElement->setAttribute("base", $parentType); } $plugin = $this->extractPluginNameFromPackage($typeReflector->getPackage()); if ($plugin) { $classElement->setAttribute("plugin", $plugin); } $description = $typeReflector->getDescription(); $description = $this->fixDescription($description); $classElement->setAttribute("description", $description); $properties = $typeReflector->getCurrentProperties(); foreach ($properties as $property) { /* @var $property KalturaPropertyInfo */ if ($property->isServerOnly()) { continue; } $propType = $property->getType(); $propName = $property->getName(); $propertyElement = $this->_doc->createElement("property"); $propertyElement->setAttribute("name", $propName); if ($property->isAssociativeArray()) { $propertyElement->setAttribute("type", "map"); $propertyElement->setAttribute("arrayType", $property->getArrayType()); } else { if ($property->isArray()) { $propertyElement->setAttribute("type", "array"); $propertyElement->setAttribute("arrayType", $property->getArrayType()); } else { if ($property->isEnum()) { $propertyElement->setAttribute("type", "int"); $propertyElement->setAttribute("enumType", $property->getType()); } else { if ($property->isStringEnum()) { $propertyElement->setAttribute("type", "string"); $propertyElement->setAttribute("enumType", $property->getType()); } else { if ($propType == 'KalturaObject') { $propertyElement->setAttribute("type", 'KalturaObjectBase'); } else { $propertyElement->setAttribute("type", $propType); } } } } } $propertyElement->setAttribute("readOnly", $property->isReadOnly() ? "1" : "0"); $propertyElement->setAttribute("insertOnly", $property->isInsertOnly() ? "1" : "0"); $description = $property->getDescription(); $description = $this->fixDescription($description); $propertyElement->setAttribute("description", $description); $classElement->appendChild($propertyElement); } return $classElement; }
private static function loadClassRecursively(KalturaTypeReflector $classTypeReflector, &$enumClasses) { $class = $classTypeReflector->getType(); if ($class == 'KalturaEnum' || $class == 'KalturaStringEnum' || $class == 'KalturaObject') { return; } $enumClasses[$class] = $classTypeReflector; $parentClassTypeReflector = $classTypeReflector->getParentTypeReflector(); if ($parentClassTypeReflector) { self::loadClassRecursively($parentClassTypeReflector, $enumClasses); } }
private function getClassElement(KalturaTypeReflector $typeReflector) { $properties = $typeReflector->getProperties(); $classElement = $this->_doc->createElement("class"); $classElement->setAttribute("name", $typeReflector->getType()); $parentTypeReflector = $typeReflector->getParentTypeReflector(); if ($typeReflector->isAbstract()) { $classElement->setAttribute("abstract", true); } if ($parentTypeReflector) { $parentType = $parentTypeReflector->getType(); $classElement->setAttribute("base", $parentType); } $package = $typeReflector->getPackage(); if (is_string($package)) { $packages = explode('.', $package, 2); if (count($packages) == 2 && $packages[0] == 'plugins') { $classElement->setAttribute("plugin", $packages[1]); } } $properties = $typeReflector->getCurrentProperties(); foreach ($properties as $property) { $propType = $property->getType(); $propName = $property->getName(); $propertyElement = $this->_doc->createElement("property"); $propertyElement->setAttribute("name", $propName); if ($property->isArray()) { $propertyElement->setAttribute("type", "array"); $propertyElement->setAttribute("arrayType", $property->getArrayType()); } else { if ($property->isEnum()) { $propertyElement->setAttribute("type", "int"); $propertyElement->setAttribute("enumType", $property->getType()); } else { if ($property->isStringEnum()) { $propertyElement->setAttribute("type", "string"); $propertyElement->setAttribute("enumType", $property->getType()); } else { $propertyElement->setAttribute("type", $propType); } } } $propertyElement->setAttribute("readOnly", $property->isReadOnly() ? "1" : "0"); $propertyElement->setAttribute("insertOnly", $property->isInsertOnly() ? "1" : "0"); $description = $property->getDescription(); $description = $this->fixDescription($description); $propertyElement->setAttribute("description", $description); $classElement->appendChild($propertyElement); } return $classElement; }
private function getTypeDependencies(KalturaTypeReflector $typeReflector) { $result = array(); $parentTypeReflector = $typeReflector->getParentTypeReflector(); if ($parentTypeReflector) { $result[$parentTypeReflector->getType()] = $parentTypeReflector; } $properties = $typeReflector->getProperties(); foreach ($properties as $property) { $subTypeReflector = $property->getTypeReflector(); if ($subTypeReflector) { $result[$subTypeReflector->getType()] = $subTypeReflector; } } if ($typeReflector->isArray() && !$typeReflector->isAbstract()) { $arrayTypeReflector = KalturaTypeReflectorCacher::get($typeReflector->getArrayType()); if ($arrayTypeReflector) { $result[$arrayTypeReflector->getType()] = $arrayTypeReflector; } } return $result; }
private function loadTypesRecursive(KalturaTypeReflector $typeReflector) { $parentTypeReflector = $typeReflector->getParentTypeReflector(); if ($parentTypeReflector) { $parentType = $parentTypeReflector->getType(); $this->loadTypesRecursive($parentTypeReflector); } $properties = $typeReflector->getProperties(); foreach ($properties as $property) { $subTypeReflector = $property->getTypeReflector(); if ($subTypeReflector) { $this->loadTypesRecursive($subTypeReflector); } } if ($typeReflector->isArray()) { $arrayTypeReflector = KalturaTypeReflectorCacher::get($typeReflector->getArrayType()); if ($arrayTypeReflector) { $this->loadTypesRecursive($arrayTypeReflector); } } $this->addType($typeReflector); }