public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null) { if (!is_null($this->isAnonymous)) { if (KalturaNullableBoolean::toBoolean($this->isAnonymous) === false) { if ($this->userIdNotIn == null) { $anonKuserIds = ""; $anonKusers = kuserPeer::getKuserByPartnerAndUids(kCurrentContext::getCurrentPartnerId(), array('', 0)); foreach ($anonKusers as $anonKuser) { $anonKuserIds .= $anonKuser->getKuserId() . ","; } $this->userIdNotIn = $anonKuserIds; } } } return parent::getListResponse($pager, $responseProfile); }
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; }
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; }