/** * @return boolean */ public function isAbstract() { $this->getTypeReflector(); if ($this->_typeReflector) { return $this->_typeReflector->isAbstract(); } else { return false; } }
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 function writeOrderByEnumForType(KalturaTypeReflector $type) { $map = KAutoloader::getClassMap(); if (!isset($map[$type->getType()])) { return; } $this->_txt = ""; $parentType = $type; while (1) { $parentType = $parentType->getParentTypeReflector(); if ($parentType === null || $parentType->isFilterable()) { break; } } $partnetClassName = $parentType ? $parentType->getType() . "OrderBy" : "KalturaStringEnum"; $enumName = $type->getType() . "OrderBy"; $enumPath = dirname($map[$type->getType()]) . "/filters/orderEnums/{$enumName}.php"; $subpackage = ($type->getPackage() == 'api' ? '' : 'api.') . 'filters.enum'; $this->appendLine("<?php"); $this->appendLine("/**"); $this->appendLine(" * @package " . $type->getPackage()); $this->appendLine(" * @subpackage {$subpackage}"); $this->appendLine(" */"); $this->appendLine("class {$enumName} extends {$partnetClassName}"); $this->appendLine("{"); foreach ($type->getCurrentProperties() as $prop) { $filters = $prop->getFilters(); foreach ($filters as $filter) { if ($filter == "order") { $this->appendLine("\tconst " . $this->getOrderByConst($prop->getName()) . "_ASC = \"+" . $prop->getName() . "\";"); $this->appendLine("\tconst " . $this->getOrderByConst($prop->getName()) . "_DESC = \"-" . $prop->getName() . "\";"); } } } $reflectionClass = new ReflectionClass($type->getType()); if (!$type->isAbstract() && $reflectionClass->getMethod("getExtraFilters")->getDeclaringClass()->getName() === $reflectionClass->getName()) { $extraFilters = $type->getInstance()->getExtraFilters(); if ($extraFilters) { foreach ($extraFilters as $filterFields) { if (!isset($filterFields["order"])) { continue; } $fieldName = $filterFields["order"]; $fieldConst = $this->getOrderByConst($fieldName); $this->appendLine("\tconst {$fieldConst}_ASC = \"+{$fieldName}\";"); $this->appendLine("\tconst {$fieldConst}_DESC = \"-{$fieldName}\";"); } } } $this->appendLine("}"); $this->writeToFile($enumPath, $this->_txt); }
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 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; }