Esempio n. 1
0
 /**
  * get value from global variable scopes as defined in Xapp_Rpc_Request::getFrom will
  * look in each scope / global array and if not found in any of them will return default
  * value defined in third parameter. if second parameter is not null but variable scope
  * constant name will redirect to getFrom function to get value
  *
  * @error 14411
  * @see Xapp_Rpc_Request::getFrom
  * @param string $name expects parameter name
  * @param string $from expects
  * @param null $default expects default return value
  * @return null|mixed
  */
 public function get($name, $from = null, $default = null)
 {
     $return = $default;
     if ($from !== null) {
         return $this->getFrom($name, $from, $default);
     }
     switch (true) {
         case xapp_array_isset($this->_params, $name):
             $return = xapp_array_get($this->_params, $name, $default);
             break;
         case isset($GLOBALS['_RPC']) && array_key_exists($name, $GLOBALS['_RPC']):
             $return = $GLOBALS['_RPC'][$name];
             break;
         case array_key_exists($name, $_POST):
             $return = $_POST[$name];
             break;
         case array_key_exists($name, $_GET):
             $return = $_GET[$name];
             break;
         case array_key_exists($name, $_COOKIE):
             $return = $_COOKIE[$name];
             break;
         case array_key_exists($name, $_SERVER):
             $return = $_SERVER[$name];
             break;
     }
     return $return;
 }
Esempio n. 2
0
 /**
  * get data from additional data array either by passing first parameter key returning the data for that key or
  * without first parameter returning the complete data array. if key is not found in data array will return default
  * second parameter. the key can be passed in "." notation to get data in multidimensional array
  *
  * @error 14308
  * @param null|int|string $key expects the optional key to get data for
  * @param null $default expects optional default return value
  * @return array|null
  */
 public function getData($key = null, $default = null)
 {
     if ($key !== null) {
         return $this->hasData($key) ? xapp_array_get($this->_data, $key) : $default;
     } else {
         return $this->_data;
     }
 }
Esempio n. 3
0
 /**
  * get service from smd map either as function or class or dot notation for class.method.
  * if service is not found returns default value passed in second parameter
  *
  * @error 14104
  * @param string $name expects the service to get
  * @param null $default expects the default return value
  * @return array|mixed|null
  */
 public function get($name, $default = null)
 {
     return xapp_array_get($this->map(), $name, $default);
 }
Esempio n. 4
0
 /**
  * get data from data array by key returning default value from second argument if key was not found
  *
  * @error 14507
  * @param string $key expects the name of data parameter
  * @param null $default expects the default return value
  * @return array|mixed|null
  */
 public function get($key, $default = null)
 {
     return xapp_array_get($this->_data, $key, $default);
 }
Esempio n. 5
0
 /**
  * retrieve value from array by keys with dot notation e.g. config.database.user is equivalent
  * to a multidimensional array with same keys. pass a cache array in last parameter if there
  * is already a pre compiled cache array with array keys in dot notation. if so will retrieve
  * from cache array instead from first array which is needs to iterated until finally key
  * value is found. if no key is passed will return complete array
  *
  * @error 12411
  * @param array $array expects the original array to look for key
  * @param null|string $key expects the optional key to get from array
  * @param null|mixed $default expects optional returnable default value if key is not found
  * @param null|array $cache expects optional cache array for dot notation key => value pairs
  * @return array|null
  */
 protected static function out(array $array, $key = null, $default = null, array &$cache = null)
 {
     if ($key === null) {
         return $array;
     }
     if ($cache !== null && array_key_exists($key, $cache)) {
         return $cache[$key];
     }
     if ($cache !== null) {
         return $cache[$key] = xapp_array_get($array, $key, xapp_default($default));
     } else {
         return xapp_array_get($array, $key, xapp_default($default));
     }
 }