public function toArray($withSubTypes = false, $returnedTypes = array()) { $array = parent::toArray($withSubTypes); $array["isFile"] = $this->isFile(); $array["isOptional"] = $this->isOptional(); return $array; }
function toArrayRecursive(KalturaPropertyInfo $propInfo) { return $propInfo->toArray(); }
/** * @param KalturaPropertyInfo $property */ public function validateHtmlTags($className, $property) { if ($property->getType() != 'string') { return; } $propName = $property->getName(); $value = $this->{$propName}; return kHtmlPurifier::purify($className, $propName, $value); }
public function toArray($withSubTypes = false) { $array = array(); $array["type"] = $this->getType(); $array["name"] = $this->getName(); $array["defaultValue"] = $this->getDefaultValue(); $array["isSimpleType"] = $this->isSimpleType(); $array["isComplexType"] = $this->isComplexType(); $array["isFile"] = $this->isFile(); $array["isEnum"] = $this->isEnum(); $array["isStringEnum"] = $this->isStringEnum(); $array["isArray"] = $this->isArray(); if ($this->isArray()) { $propInfo = new KalturaPropertyInfo($this->getArrayType(), "1"); $array["arrayType"] = $propInfo->toArray(); } $array["isReadOnly"] = $this->isReadOnly(); $array["isInsertOnly"] = $this->isInsertOnly(); $array["isWriteOnly"] = $this->isWriteOnly(); $array["description"] = $this->getDescription() ? $this->getDescription() : ""; $array["properties"] = array(); $array["constants"] = array(); $array["subTypes"] = array(); $typeReflector = $this->getTypeReflector(); if ($typeReflector) { if ($withSubTypes) { $subTypes = $typeReflector->getSubTypesNames(); foreach ($subTypes as $subType) { $subTypeInfo = new KalturaPropertyInfo($subType, $this->_name); $array["subTypes"][] = $subTypeInfo->toArray(); } } foreach ($typeReflector->getProperties() as $prop) { $array["properties"][] = $prop->toArray($withSubTypes); } foreach ($typeReflector->getConstants() as $prop) { $array["constants"][] = $prop->toArray(); } } return $array; }
/** * Returns the enum constants * * @return array<KalturaPropertyInfo> */ public function getConstants() { if (!is_null($this->_constants)) { return $this->_constants; } $this->_constants = array(); $constantsDescription = array(); if ($this->isEnum() || $this->isStringEnum()) { $reflectClass = new ReflectionClass($this->_type); $constantsDescription = call_user_func(array($this->_type, 'getDescriptions')); $contants = $reflectClass->getConstants(); foreach ($contants as $enum => $value) { if ($this->isEnum()) { $prop = new KalturaPropertyInfo("int", $enum); } else { $prop = new KalturaPropertyInfo("string", $enum); } if (isset($constantsDescription[$value])) { $prop->setDescription($constantsDescription[$value]); } $prop->setDefaultValue($value); $this->_constants[] = $prop; } } if ($this->isDynamicEnum()) { $type = $this->getType(); $baseEnumName = $type::getEnumClass(); $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaEnumerator'); foreach ($pluginInstances as $pluginInstance) { $pluginName = $pluginInstance->getPluginName(); $enums = $pluginInstance->getEnums($baseEnumName); foreach ($enums as $enum) { $enumConstans = $enum::getAdditionalValues(); foreach ($enumConstans as $name => $value) { $value = $pluginName . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $value; $prop = new KalturaPropertyInfo("string", $name); $prop->setDefaultValue($value); if (isset($constantsDescription[$value])) { $prop->setDescription($constantsDescription[$value]); } $this->_constants[] = $prop; } } } } return $this->_constants; }
/** * Returns the enum constants * * @return array */ public function getConstants() { if ($this->_constants === null) { $this->_constants = array(); if ($this->isEnum() || $this->isStringEnum()) { $reflectClass = new ReflectionClass($this->_type); $constantsDescription = array(); if ($reflectClass->hasMethod("getDescription")) { $constantsDescription = $reflectClass->getMethod("getDescription")->invoke($this->_instance); } $contants = $reflectClass->getConstants(); foreach ($contants as $enum => $value) { if ($this->isEnum()) { $prop = new KalturaPropertyInfo("int", $enum); } else { $prop = new KalturaPropertyInfo("string", $enum); } if (array_key_exists($value, $constantsDescription)) { $prop->setDescription($constantsDescription[$value]); } $prop->setDefaultValue($value); $this->_constants[] = $prop; } } if ($this->isDynamicEnum()) { $type = $this->getType(); // TODO remove call_user_func after moving to php 5.3 $baseEnumName = call_user_func(array($type, 'getEnumClass')); // $baseEnumName = $type::getEnumClass(); $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaEnumerator'); foreach ($pluginInstances as $pluginInstance) { $pluginName = $pluginInstance->getPluginName(); $enums = $pluginInstance->getEnums($baseEnumName); foreach ($enums as $enum) { // TODO remove call_user_func after moving to php 5.3 $enumConstans = call_user_func(array($enum, 'getAdditionalValues')); // $enumConstans = $enum::getAdditionalValues(); foreach ($enumConstans as $name => $value) { $prop = new KalturaPropertyInfo("string", $name); $prop->setDefaultValue($pluginName . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $value); $this->_constants[] = $prop; } } } } } return $this->_constants; }