/** * set parameter to global scope array by passing parameter in first * argument, value in second and destination string as third parameter. the * the third value defines to which global variable to write to e.g. "POST" * * @error 14414 * @param string $name expects the parameter name * @param null $value exepects the value for parameter * @param string $to expects optional scope value like "POST" * @return Xapp_Rpc_Request * @throws Xapp_Rpc_Request_Exception */ public function set($name, $value = null, $to = self::PARAMS) { $to = strtoupper(trim($to)); switch ($to) { case self::PARAMS: xapp_array_set($this->_params, $name, $value); break; case self::RPC: $GLOBALS['_RPC'][$name] = $value; break; case self::POST: $_POST[$name] = $value; break; case self::GET: $_GET[$name] = $value; break; case self::COOKIE: $_COOKIE[$name] = $value; break; default: throw new Xapp_Rpc_Request_Exception(xapp_sprintf(_("request variable scope: %s does not exist"), $to), 1441401); } return $this; }
/** * set additional data in key => value pairs. the first parameter must not be set if wanting to add none named * parameters to data array. key => value pairs can be set in "." notation for multidimensional arrays * * @error 14307 * @param null|string $key expects optional data key name * @param null|mixed $value expects value to set * @return Xapp_Rpc_Fault */ public function setData($key = null, $value = null) { if ($key !== null) { xapp_array_set($this->_data, (string) $key, $value); } else { $this->_data[] = $value; } return $this; }
/** * maps a function, a class or object or a directory of classes with all details/smd * properties found for the passed first parameter. this function is only called by server * instance since functions and classes need to be registered by server. all mapped * functions and classes will be stored as smd map and service map to quick check if service * has been mapped or not. the second parameter can contain array of methods to ignore when * passing only class as first parameter * * @see Xapp_Rpc_Server::register * @error 14102 * @param null|string|object $mixed expects any of the above explained values * @param null|array $ignore expects methods to ignore as array or null for no ignores * @return array */ public final function map($mixed = null, $ignore = null) { if ($mixed !== null) { if (!is_object($mixed)) { if (stristr((string) $mixed, DS) !== false) { $mixed = $this->getClasses($mixed); } else { $mixed = array($mixed); } } else { $mixed = array($mixed); } foreach ($mixed as $m) { $tmp = array(); //assume function if (is_string($m) && function_exists($m)) { $map = $this->mapFunction($m); if (!array_key_exists($m, $this->_services)) { $this->_services[] = $m; } if ($map !== null) { xapp_array_set($tmp, $m, $map); } //assume class and/or method } else { $map = $this->mapClass($m, $ignore); $class = $this->getClass($m); if (array_key_exists($class, $this->_services)) { $this->_services[$class] = array(); } foreach ($map as $k => $v) { $this->_services[$class][] = $k; xapp_array_set($tmp, "{$class}.{$k}", $v); } } $this->_map = array_merge($this->_map, $tmp); } } return $this->_map; }
/** * set data to data array by key => value pair * * @error 14506 * @param string $key expects name of data parameter * @param null|mixed $value expects value of data parameter * @return Xapp_Rpc_Response */ public function set($key, $value = null) { xapp_array_set($this->_data, $key, $value); return $this; }
/** * inject key => value pair into first parameter array. key => value pairs can be passed * as single array in second parameter $key or as key => value pair over second and third * parameter * * @error 12410 * @param array $array expects the array to inject key into * @param string|array $key expects key as string or key => value pairs * @param null|mixed $val expects optional value * @return void */ protected static function in(array &$array, $key, $val = null) { if (is_array($key) && $val === null) { //do nothing } else { $key = array($key => $val); } foreach ($key as $k => $v) { xapp_array_set($array, $k, $v); } }