本文整理汇总了PHP中kCurrentContext::client_lang方法的典型用法代码示例。如果您正苦于以下问题:PHP kCurrentContext::client_lang方法的具体用法?PHP kCurrentContext::client_lang怎么用?PHP kCurrentContext::client_lang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kCurrentContext
的用法示例。
在下文中一共展示了kCurrentContext::client_lang方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
public function dispatch($service, $action, $params = array())
{
KalturaLog::debug("Dispatching service [" . $service . "], action [" . $action . "] with params " . print_r($params, true));
$start = microtime(true);
// prevent impersonate to partner zero
$p = isset($params["p"]) && $params["p"] ? $params["p"] : null;
if (!$p) {
$p = isset($params["partnerId"]) && $params["partnerId"] ? $params["partnerId"] : null;
}
$GLOBALS["partnerId"] = $p;
// set for logger
$userId = "";
$ksStr = isset($params["ks"]) ? $params["ks"] : null;
if (!$service) {
throw new KalturaAPIException(KalturaErrors::SERVICE_NOT_SPECIFIED);
}
try {
// load the service reflector
$reflector = new KalturaServiceReflector($service);
} catch (Exception $ex) {
throw new KalturaAPIException(KalturaErrors::SERVICE_DOES_NOT_EXISTS, $service);
}
// check if action exists
if (!$action) {
throw new KalturaAPIException(KalturaErrors::ACTION_NOT_SPECIFIED, $service);
}
if (!$reflector->isActionExists($action)) {
throw new KalturaAPIException(KalturaErrors::ACTION_DOES_NOT_EXISTS, $action, $service);
}
$actionParams = $reflector->getActionParams($action);
// services.ct - check if partner is allowed to access service ...
// validate it's ok to access this service
$deserializer = new KalturaRequestDeserializer($params);
$arguments = $deserializer->buildActionArguments($actionParams);
$serviceInstance = $reflector->getServiceInstance();
kCurrentContext::$host = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : null;
kCurrentContext::$user_ip = requestUtils::getRemoteAddress();
kCurrentContext::$ps_vesion = "ps3";
kCurrentContext::$service = $reflector->getServiceName();
kCurrentContext::$action = $action;
kCurrentContext::$client_lang = isset($params['clientTag']) ? $params['clientTag'] : null;
kCurrentContext::initKsPartnerUser($ksStr, $p, $userId);
kPermissionManager::init(kConf::get('enable_cache'));
// initialize the service before invoking the action on it
$serviceInstance->initService($reflector->getServiceId(), $reflector->getServiceName(), $action);
$invokeStart = microtime(true);
KalturaLog::debug("Invoke start");
$res = $reflector->invoke($action, $arguments);
KalturaLog::debug("Invoke took - " . (microtime(true) - $invokeStart) . " seconds");
KalturaLog::debug("Disptach took - " . (microtime(true) - $start) . " seconds");
$this->clearMemory();
return $res;
}
示例2: dispatch
public function dispatch($service, $action, $params = array())
{
$start = microtime(true);
// prevent impersonate to partner zero
$p = isset($params["p"]) && $params["p"] ? $params["p"] : null;
if (!$p) {
$p = isset($params["partnerId"]) && $params["partnerId"] ? $params["partnerId"] : null;
}
$GLOBALS["partnerId"] = $p;
// set for logger
$userId = "";
$ksStr = isset($params["ks"]) ? $params["ks"] : null;
if (!$service) {
throw new KalturaAPIException(KalturaErrors::SERVICE_NOT_SPECIFIED);
}
//strtolower on service - map is indexed according to lower-case service IDs
$service = strtolower($service);
$serviceActionItem = KalturaServicesMap::retrieveServiceActionItem($service, $action);
$action = strtolower($action);
if (!isset($serviceActionItem->actionMap[$action])) {
KalturaLog::crit("Action does not exist!");
throw new KalturaAPIException(KalturaErrors::ACTION_DOES_NOT_EXISTS, $action, $service);
}
try {
$actionReflector = new KalturaActionReflector($service, $action, $serviceActionItem->actionMap[$action]);
} catch (Exception $e) {
throw new Exception("Could not create action reflector for service [{$service}], action [{$action}]. Received error: " . $e->getMessage());
}
$actionParams = $actionReflector->getActionParams();
$actionInfo = $actionReflector->getActionInfo();
// services.ct - check if partner is allowed to access service ...
kCurrentContext::$host = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : gethostname();
kCurrentContext::$user_ip = requestUtils::getRemoteAddress();
kCurrentContext::$ps_vesion = "ps3";
kCurrentContext::$service = $serviceActionItem->serviceInfo->serviceName;
kCurrentContext::$action = $action;
kCurrentContext::$client_lang = isset($params['clientTag']) ? $params['clientTag'] : null;
kCurrentContext::initKsPartnerUser($ksStr, $p, $userId);
// validate it's ok to access this service
$deserializer = new KalturaRequestDeserializer($params);
$this->arguments = $deserializer->buildActionArguments($actionParams);
KalturaLog::debug("Dispatching service [" . $service . "], action [" . $action . "], reqIndex [" . kCurrentContext::$multiRequest_index . "] with params " . print_r($this->arguments, true));
$responseProfile = $deserializer->getResponseProfile();
if ($responseProfile) {
KalturaLog::debug("Response profile: " . print_r($responseProfile, true));
}
kPermissionManager::init(kConf::get('enable_cache'));
kEntitlementUtils::initEntitlementEnforcement();
$disableTags = $actionInfo->disableTags;
if ($disableTags && is_array($disableTags) && count($disableTags)) {
foreach ($disableTags as $disableTag) {
KalturaCriterion::disableTag($disableTag);
}
}
if ($actionInfo->validateUserObjectClass && $actionInfo->validateUserIdParamName && isset($actionParams[$actionInfo->validateUserIdParamName])) {
// // TODO maybe if missing should throw something, maybe a bone?
// if(!isset($actionParams[$actionInfo->validateUserIdParamName]))
// throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, $actionInfo->validateUserIdParamName);
KalturaLog::debug("validateUserIdParamName: " . $actionInfo->validateUserIdParamName);
$objectId = $params[$actionInfo->validateUserIdParamName];
$this->validateUser($actionInfo->validateUserObjectClass, $objectId, $actionInfo->validateUserPrivilege, $actionInfo->validateOptions);
}
// initialize the service before invoking the action on it
// action reflector will init the service to maintain the pluginable action transparency
$actionReflector->initService($responseProfile);
$invokeStart = microtime(true);
KalturaLog::debug("Invoke start");
try {
$res = $actionReflector->invoke($this->arguments);
} catch (KalturaAPIException $e) {
if ($actionInfo->returnType != 'file') {
throw $e;
}
KalturaResponseCacher::adjustApiCacheForException($e);
$res = new kRendererDieError($e->getCode(), $e->getMessage());
}
kEventsManager::flushEvents();
KalturaLog::debug("Invoke took - " . (microtime(true) - $invokeStart) . " seconds");
KalturaLog::debug("Dispatch took - " . (microtime(true) - $start) . " seconds, memory: " . memory_get_peak_usage(true));
return $res;
}