public function write($data) { $pass = null; if (xapp_has_option(self::CONF_PASSWORD)) { $pass = xapp_get_option(self::CONF_PASSWORD); } return XApp_Utils_JSONUtils::write_json(xo_get(self::CONF_FILE, $this), $data, 'json', true, $pass); }
/** * @param $key * @param $opt */ protected function setGatewayOptionArray($key, &$opt) { if (xapp_has_option($key, $opt) && is_array(xapp_get_option($key, $opt))) { } else { unset($opt[$key]); } }
public function setup() { /*** * The very basic paths */ if (!defined('XAPP_BASEDIR')) { define("XAPP_BASEDIR", xapp_get_option(self::BASEDIR, $this)); } if (!defined('XAPP_LIB')) { define("XAPP_LIB", XAPP_BASEDIR . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR); } /*** * Load utils */ if (!class_exists('XApp_Service_Entry_Utils')) { include_once XAPP_BASEDIR . 'XApp_Service_Entry_Utils.php'; } /*** * Get run-time configuration, there is 'debug' and 'release'. For both cases there are * different resources to load. */ $XAPP_RUN_TIME_CONFIGURATION = XApp_Service_Utils::_getKey('rtConfig', XApp_Service_Entry_Utils::getRunTimeConfiguration()); /*** * Now include all xapp stuff */ //pull in parts of xapp core framework XApp_Service_Entry_Utils::includeXAppCore(); //pull in registry of xapp core framework XApp_Service_Entry_Utils::includeXAppRegistry(); //pull in parts of xapp json framework XApp_Service_Entry_Utils::includeXAppJSONStoreClasses(); //pull in json utils (to read client app's resource configuration XApp_Service_Entry_Utils::includeXAppJSONTools(); //some debugging tools XApp_Service_Entry_Utils::includeXAppDebugTools(); //pull in legacy client app renderer xapp_import('xapp.app.Renderer'); self::loadCommons(); //pull in xapp commander renderer /*include_once(XAPP_BASEDIR . DIRECTORY_SEPARATOR . 'app'. DIRECTORY_SEPARATOR . 'Commander.php');*/ //pull in xapp resource renderer include_once XAPP_BASEDIR . '/Resource/Renderer.php'; //pull in xapp resource renderer xapp_import('xapp.commander.Resource.Renderer'); //pull in xapp resource renderer xapp_import('xapp.Resource.Renderer'); //pull in xide resource Renderer xapp_import('xapp.xide.Resource.Renderer'); //pull in xide resource Renderer //xapp_import('xapp.xcf.Resource.Renderer'); //pull in cms related resource renderer include_once XAPP_LIB . DIRECTORY_SEPARATOR . xapp_get_option(self::RESOURCE_RENDERER_PREFIX, $this) . DIRECTORY_SEPARATOR . 'ResourceRenderer.php'; /*** * Prepare resource renderer */ //clients resource config path $XAPP_RESOURCE_CONFIG_PATH = '' . xapp_get_option(self::APPDIR, $this) . DIRECTORY_SEPARATOR; $XAPP_RESOURCE_CONFIG = xapp_get_option(self::XAPP_RESOURCE_CONFIG, $this); if (strlen($XAPP_RESOURCE_CONFIG)) { if ($XAPP_RUN_TIME_CONFIGURATION === 'debug') { $XAPP_RESOURCE_CONFIG_PATH .= 'lib' . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . $XAPP_RESOURCE_CONFIG . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json'; } else { if ($XAPP_RUN_TIME_CONFIGURATION === 'release') { $XAPP_RESOURCE_CONFIG_PATH .= DIRECTORY_SEPARATOR . xapp_get_option(self::APP_FOLDER, $this) . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . $XAPP_RESOURCE_CONFIG . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json'; } } } else { if ($XAPP_RUN_TIME_CONFIGURATION === 'debug') { $XAPP_RESOURCE_CONFIG_PATH .= 'lib' . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . 'resources-' . $XAPP_RUN_TIME_CONFIGURATION . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json'; } else { if ($XAPP_RUN_TIME_CONFIGURATION === 'release') { $XAPP_RESOURCE_CONFIG_PATH .= DIRECTORY_SEPARATOR . xapp_get_option(self::APP_FOLDER, $this) . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . 'resources-' . $XAPP_RUN_TIME_CONFIGURATION . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json'; } } } //error_log('$XAPP_RESOURCE_CONFIG ' . $XAPP_RESOURCE_CONFIG . " = " . $XAPP_RESOURCE_CONFIG_PATH); if (!file_exists($XAPP_RESOURCE_CONFIG_PATH)) { $this->log('have no core resources, ' . $XAPP_RESOURCE_CONFIG_PATH . ' doesnt exists'); return null; } $resources = (object) XApp_Utils_JSONUtils::read_json($XAPP_RESOURCE_CONFIG_PATH, 'json', false, true); $pluginResources = null; /*** * Load plugin resources */ if (xapp_get_option(self::ALLOW_PLUGINS, $this) && xapp_get_option(self::PLUGIN_DIRECTORY, $this) && xapp_get_option(self::PLUGIN_DIRECTORY, $this)) { //pull in xapp plugin manager include_once XAPP_BASEDIR . '/commander/PluginManager.php'; //pull in xapp commander plugin base class include_once XAPP_BASEDIR . '/commander/Plugin.php'; //pull in RPC interface if (!class_exists('Xapp_Rpc_Interface_Callable')) { //pull in xapp commander plugin base class include_once XAPP_BASEDIR . '/Rpc/Interface/Callable.php'; } $xComPluginManager = new XApp_Commander_PluginManager(); $loadedPlugins = null; $plugins = $xComPluginManager->loadPlugins(xapp_get_option(self::PLUGIN_DIRECTORY, $this), xapp_get_option(self::PLUGIN_DIRECTORY, $this), xapp_get_option(self::PLUGIN_MASK, $this)); $pluginResources = $this->getPluginResources($plugins, $XAPP_RUN_TIME_CONFIGURATION, $XAPP_RESOURCE_CONFIG); } //error_log('flags ' . json_encode(xapp_get_option(self::FLAGS, $this))); //now merge into app resources, filtered if ($pluginResources) { foreach ($pluginResources as $pluginResourceItems) { foreach ($pluginResourceItems as $pluginResource) { $prohibited = explode(',', xapp_get_option(self::PROHIBITED_PLUGINS, $this)); if (property_exists($pluginResource, 'type') && property_exists($pluginResource, 'name')) { //is plugin item if (in_array('X' . $pluginResource->name, $prohibited)) { continue; } else { array_push($resources->items, $pluginResource); } } else { array_push($resources->items, $pluginResource); } } } } $resourceRendererOptions = array(XApp_Resource_Renderer::DOC_ROOT => xapp_get_option(self::DOC_ROOT, $this), XApp_Resource_Renderer::DOC_ROOT_PATH => xapp_get_option(self::APPDIR, $this), XApp_Resource_Renderer::RESOURCES_DATA => $resources, XApp_Resource_Renderer::RENDER_DELEGATE => xapp_get_option(self::RENDER_DELEGATE, $this)); $clz = xapp_get_option(self::RESOURCE_RENDERER_CLZ, $this); $xappResourceRenderer = new $clz($resourceRendererOptions); $xappResourceRenderer->registerDefault(); if (xapp_has_option(self::RELATIVE_VARIABLES)) { $rVariables = xapp_get_option(self::RELATIVE_VARIABLES, $this); if ($rVariables != null && count($rVariables)) { foreach ($rVariables as $variable => $value) { $xappResourceRenderer->registerRelative($variable, $value); } } } $XAPP_DOJO_PACKAGES = '[]'; $XAPP_DOJO_PACKAGE_LOCATION_PREFIX = $xappResourceRenderer->resolveRelative('%PLUGIN_PACKAGE_ROOT_URL%'); $javascriptPlugins = $xappResourceRenderer->getJavascriptPlugins(); if ($javascriptPlugins && count($javascriptPlugins)) { if (XApp_Service_Entry_Utils::isDebug()) { $dojoPackages = array(); $dojoPackagesStr = '['; $pIdx = 0; foreach ($javascriptPlugins as $plugin) { if (!is_object($plugin)) { continue; } if ($pIdx > 0) { $dojoPackagesStr .= ","; } $dojoPackagesStr .= "{name:" . "'" . $plugin->name . "',"; if (property_exists($plugin, 'packageLocation')) { $dojoPackagesStr .= "location:" . "'" . $plugin->packageLocation . "'}"; } else { $dojoPackagesStr .= "location:" . "'" . $XAPP_DOJO_PACKAGE_LOCATION_PREFIX . $plugin->name . '/client/' . "'}"; } if ($pIdx < count($javascriptPlugins) - 1) { $dojoPackagesStr .= ','; } } $dojoPackagesStr .= ']'; $XAPP_DOJO_PACKAGES = $dojoPackagesStr; } else { $packageSuffix = ""; $dojoPackages = array(); array_push($dojoPackages, array('name' => 'dojo', 'location' => 'dojo')); array_push($dojoPackages, array('name' => 'dojox', 'location' => 'dojox')); array_push($dojoPackages, array('name' => 'dijit', 'location' => 'dijit')); array_push($dojoPackages, array('name' => 'cbtree', 'location' => 'cbtree')); array_push($dojoPackages, array('name' => 'xfile', 'location' => 'xfile')); array_push($dojoPackages, array('name' => 'xide', 'location' => 'xide')); array_push($dojoPackages, array('name' => 'xwordpress', 'location' => 'xwordpress')); array_push($dojoPackages, array('name' => 'xbox', 'location' => 'xbox')); array_push($dojoPackages, array('name' => 'xjoomla', 'location' => 'xjoomla')); foreach ($javascriptPlugins as $plugin) { if (is_object($plugin)) { if (property_exists($plugin, 'packageSuffix')) { $packageSuffix = $plugin->{'packageSuffix'}; } $packageLocation = $XAPP_DOJO_PACKAGE_LOCATION_PREFIX . $plugin->name . '/client/'; if (strlen($packageSuffix)) { $packageLocation .= $packageSuffix . '/'; } if (property_exists($plugin, 'packageLocation')) { $packageLocation = $plugin->packageLocation; } array_push($dojoPackages, array('name' => $plugin->name, 'location' => $packageLocation)); } } $XAPP_DOJO_PACKAGES = json_encode($dojoPackages); } /**** * Render plugin resources */ $javaScriptHeaderStr = ''; $javaScriptHeaderStr .= 'var xappPluginResources='; $javaScriptHeaderStr .= json_encode($javascriptPlugins) . ';'; $javaScriptHeaderStr .= ''; $xappResourceRenderer->registerRelative('XAPP_PLUGIN_RESOURCES', json_encode($javascriptPlugins)); //important: get the resource variables before adding 'head' otherwise it breaks the JSON structure! $resourceVariables = (array) $xappResourceRenderer->registryToKeyValues(xapp_get_option(XApp_Resource_Renderer::RELATIVE_REGISTRY_NAMESPACE, $xappResourceRenderer)); $resourceVariables['HTML_HEADER'] = array(); $resourceVariables['XAPP_PLUGIN_RESOURCES'] = $javascriptPlugins; $resourceVariables['DOJOPACKAGES'] = array(); $resourceVariables['XFILE_CONFIG_MIXIN'] = array(); $resourceVariables['RESOURCE_VARIABLES'] = array(); $xappResourceRenderer->registerRelative('RESOURCE_VARIABLES', Xapp_Util_Json::prettify(json_encode($resourceVariables, true)), LOCK_EX); } $xappResourceRenderer->registerRelative('DOJOPACKAGES', $XAPP_DOJO_PACKAGES); $pConfigDefault = $xappResourceRenderer->resolveRelative('%PACKAGE_CONFIG%'); if (!strlen($pConfigDefault)) { $pConfigDefault = 'run-release-debug'; } //error_log('$pConfigDefault ' .$pConfigDefault); $xappResourceRenderer->registerRelative('PACKAGE_CONFIG', XApp_Service_Utils::_getKey('pConfig', $pConfigDefault)); /**** * Build XApp-App-Renderer - Config */ $opt = array(XApp_App_Commander::DOC_ROOT_PATH => xapp_get_option(self::APPDIR, $this), XApp_App_Commander::DOC_ROOT => xapp_get_option(self::DOC_ROOT, $this), XApp_App_Commander::APP_NAME => xapp_get_option(self::APP_NAME, $this), XApp_App_Commander::APP_FOLDER => xapp_get_option(self::APP_FOLDER, $this), XApp_App_Commander::CONFIG_NAME => $XAPP_RUN_TIME_CONFIGURATION, XApp_App_Commander::SERVICE_URL => xapp_get_option(self::SERVICE, $this), XApp_App_Commander::RESOURCE_RENDERER => $xappResourceRenderer); $xappAppRenderer = new XApp_App_Commander($opt); $this->appRenderer = $xappAppRenderer; $this->resourceRenderer = $xappResourceRenderer; return $xappAppRenderer; }
public function setup() { $this->loadMin(); /*** * Get run-time configuration, there is 'debug' and 'release'. For both cases there are * different resources to load. */ $XAPP_RUN_TIME_CONFIGURATION = XApp_Service_Entry_Utils::getRunTimeConfiguration(); /*** * Now include all xapp stuff */ //pull in registry of xapp core framework XApp_Service_Entry_Utils::includeXAppRegistry(); //pull in parts of xapp json framework self::loadXAppJSONStoreClasses(); //pull in json utils (to read client app's resource configuration self::loadJSONTools(); //some debugging tools self::loadDebuggingTools(); //pull in legacy client app renderer xapp_import('xapp.app.Renderer'); //pull in xapp resource renderer xapp_import('xapp.Resource.Renderer'); //pull in custom resource Renderer xapp_import('xapp.xide.Resource.Renderer'); /*** * Prepare resource renderer */ //clients resource config path $XAPP_RESOURCE_CONFIG_PATH = '' . xapp_get_option(self::APPDIR, $this) . DIRECTORY_SEPARATOR; if ($XAPP_RUN_TIME_CONFIGURATION === 'debug') { $XAPP_RESOURCE_CONFIG_PATH .= 'lib' . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . 'resources-' . $XAPP_RUN_TIME_CONFIGURATION . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json'; } else { if ($XAPP_RUN_TIME_CONFIGURATION === 'release') { $XAPP_RESOURCE_CONFIG_PATH .= DIRECTORY_SEPARATOR . xapp_get_option(self::APP_FOLDER, $this) . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . 'resources-' . $XAPP_RUN_TIME_CONFIGURATION . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json'; } } if (!file_exists($XAPP_RESOURCE_CONFIG_PATH)) { $this->log('have no client resource configuration at ' . $XAPP_RESOURCE_CONFIG_PATH . ', aborting'); } //load resource configuration $resources = (object) XApp_Utils_JSONUtils::read_json($XAPP_RESOURCE_CONFIG_PATH, 'json', false, true); $pluginResources = null; $resourceRendererOptions = array(XApp_Resource_Renderer::DOC_ROOT => xapp_get_option(self::DOC_ROOT, $this), XApp_Resource_Renderer::DOC_ROOT_PATH => xapp_get_option(self::APPDIR, $this), XApp_Resource_Renderer::RESOURCES_DATA => $resources); $clz = xapp_get_option(self::RESOURCE_RENDERER_CLZ, $this); $xappResourceRenderer = new $clz($resourceRendererOptions); $xappResourceRenderer->registerDefault(); if (xapp_has_option(self::RELATIVE_VARIABLES)) { $rVariables = xapp_get_option(self::RELATIVE_VARIABLES, $this); foreach ($rVariables as $variable => $value) { $xappResourceRenderer->registerRelative($variable, $value); } } //determine Dojo package paths and store them as JSON serialized resource variable $XAPP_DOJO_PACKAGE_LOCATION_PREFIX = $xappResourceRenderer->resolveRelative('%PLUGIN_PACKAGE_ROOT_URL%'); $javascriptPlugins = $xappResourceRenderer->getJavascriptPlugins(); $dojoPackages = $this->getDojoPackages($XAPP_DOJO_PACKAGE_LOCATION_PREFIX, $javascriptPlugins, XApp_Service_Entry_Utils::isDebug()); $xappResourceRenderer->registerRelative('XAPP_PLUGIN_RESOURCES', $dojoPackages['plugins']); $xappResourceRenderer->registerRelative('DOJOPACKAGES', $dojoPackages['packages']); /**** * Build XApp-App-Renderer - Config */ $opt = array(XApp_App_Renderer::DOC_ROOT_PATH => xapp_get_option(self::APPDIR, $this), XApp_App_Renderer::DOC_ROOT => xapp_get_option(self::DOC_ROOT, $this), XApp_App_Renderer::APP_NAME => xapp_get_option(self::APP_NAME, $this), XApp_App_Renderer::APP_FOLDER => xapp_get_option(self::APP_FOLDER, $this), XApp_App_Renderer::CONFIG_NAME => $XAPP_RUN_TIME_CONFIGURATION, XApp_App_Renderer::SERVICE_URL => xapp_get_option(self::SERVICE, $this), XApp_App_Renderer::RESOURCE_RENDERER => $xappResourceRenderer); $this->appRenderer = new XApp_App_Renderer($opt); $this->resourceRenderer = xo_get(XApp_App_Renderer::RESOURCE_RENDERER, $this->appRenderer); }
public function initVariables() { $resourceData = xo_get(self::RESOURCES_DATA, $this); if (is_string($resourceData)) { xo_set(self::RESOURCES_DATA, (object) XApp_Utils_JSONUtils::read_json($resourceData, 'json', false, true), $this); } if (xapp_has_option(self::RELATIVE_VARIABLES)) { $rVariables = xapp_get_option(self::RELATIVE_VARIABLES, $this); if (count($rVariables)) { foreach ($rVariables as $variable => $value) { $this->registerRelative($variable, $value); } } } if (xapp_has_option(self::ABSOLUTE_VARIABLES)) { $variables = xapp_get_option(self::ABSOLUTE_VARIABLES, $this); if (count($variables)) { foreach ($variables as $variable => $value) { $this->registerAbsolute($variable, $value); } } } }
/** * init server by extracting class and function/method value from service parameter found * in $_GET parameter. the service must be always contained in service parameter and can also * be set by htaccess rewrite rule resolving the url path to service $_GET parameter like: * http://foo.com/gateway/class.method. resulting in service $_GET parameter service=class.method * which can be resolved by server to method/function and class. will remove all additional parameter * from get array so params array only contains parameter needed for method or function call. Use namespace * identifier RPC_SERVER_NAMESPACE_IDENTIFIER, defaults to "/" to resolve complex class names/paths like # * http://foo.com/gateway/Api/Foo/User.login to class "Api/Foo/User" and method "login". * * @error 14704 * @return void * @throws Xapp_Rpc_Fault */ protected function init() { $get = $this->request()->getGet(); $params = null; $service = $this->_service; $response = $this->response(); if (!empty($get)) { if (array_key_exists('service', $get)) { unset($get['service']); } if (array_key_exists(xapp_get_option(self::CALLBACK, $this), $get)) { unset($get[xapp_get_option(self::CALLBACK, $this)]); } if (xapp_is_option(self::ADDITIONAL_PARAMETERS, $this)) { foreach (xapp_get_option(self::ADDITIONAL_PARAMETERS, $this) as $k => $v) { if (array_key_exists($k, $get)) { unset($get[$k]); } } } $params = !empty($get) ? $get : null; } if ($service !== null) { if (strpos($service, xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this)) !== false) { $call = explode(xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this), trim($service, ' ' . xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this))); $this->_calls[] = array($this->_services[] = $call[0] . xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this) . $call[1], $call[1], $call[0], $params, self::CALL); } else { $this->_calls[] = array($this->_services[] = $service, $service, null, $params, self::CALL); } } if (xapp_has_option(self::DOJO_COMPATIBLE, $this)) { xapp_set_option(Xapp_Rpc_Response_Json::DOJO_COMPATIBLE, xapp_get_option(self::DOJO_COMPATIBLE, $this), $response); } $get = null; $params = null; $service = null; $response = null; }
/** * Assigns static properties "$optionsDict,$optionsRule,$optionsPreprocessor" to $destinationObject * * * @param $destinationObject * @param $optionsDict * @param $optionsRule * @param $optionsPreprocessor */ public static function optionfy($destinationObject, $optionsDict, $optionsRule, $optionsPreprocessor) { if (isset($destinationObject::${self::OPTIONS_DICT})) { $destinationObject::${self::OPTIONS_DICT} = $optionsDict; } if (isset($destinationObject::${self::OPTIONS_RULE})) { $destinationObject::${self::OPTIONS_RULE} = $optionsRule; } if (isset($destinationObject::${self::OPTIONS_PREPROCESSORS})) { $destinationObject::${self::OPTIONS_PREPROCESSORS} = $optionsPreprocessor; } xapp_has_option(); }
private function initVariables() { if (xapp_has_option(self::RELATIVE_VARIABLES)) { $rVariables = xapp_get_option(self::RELATIVE_VARIABLES, $this); if (count($rVariables)) { foreach ($rVariables as $variable => $value) { $this->registerRelative($variable, $value); } } } if (xapp_has_option(self::ABSOLUTE_VARIABLES)) { $variables = xapp_get_option(self::ABSOLUTE_VARIABLES, $this); if (count($variables)) { foreach ($variables as $variable => $value) { if (!XApp_Utils_Strings::endsWith($value, DIRECTORY_SEPARATOR)) { $value .= DIRECTORY_SEPARATOR; } $this->registerAbsolute($variable, $value); } } } }
public function createToken($what) { $authDelegate = xapp_has_option(self::AUTH_DELEGATE) ? xapp_get_option(self::AUTH_DELEGATE) : null; $result = ''; if ($authDelegate) { $result = $authDelegate->createToken($what); } return $result; }
/** * init server by checking for json object and method parameter or service $_GET parameter * to extract class and method or function to invoke from request. throw fault if server does * not allow functions just class methods. pass class options to response and store parameters * from json request object in param variable * * @error 14603 * @return void * @throws Xapp_Rpc_Fault */ protected function init() { $params = $this->request()->getParams(); $response = $this->response(); if (!empty($this->_service)) { $service = trim($this->_service, ' ._/'); } else { $service = null; } if (is_array($params) && !array_key_exists(0, $params)) { $params = array($params); } if (count($_FILES)) { $this->initWithUpload(); return; } foreach ((array) $params as $p) { if (is_array($p) && array_key_exists('method', $p) && !empty($p['method'])) { $type = array_key_exists('id', $p) ? self::CALL : self::NOTIFICATION; if (strpos($p['method'], xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this)) !== false) { $call = explode(xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this), trim($p['method'], ' ' . xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this))); $this->_calls[] = array($this->_services[] = $call[0] . xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this) . $call[1], $call[1], $call[0], $p, $type); } else { if (!is_null($service)) { $this->_calls[] = array($this->_services[] = $service . xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this) . $p['method'], $p['method'], $service, $p, $type); } else { $this->_calls[] = array($this->_services[] = $p['method'], $p['method'], null, $p, $type); } } } } if (empty($this->_calls) && !is_null($service)) { $type = array_key_exists('id', $params[0]) ? self::CALL : self::NOTIFICATION; if (strpos($service, xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this)) !== false) { $call = explode(xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this), trim($service, ' ' . xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this))); $this->_calls[] = array($this->_services[] = $call[0] . xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this) . $call[1], $call[1], $call[0], $params[0], $type); } else { $this->_calls[] = array($this->_services[] = $service, $service, null, $params[0], $type); } } if (xapp_has_option(self::DOJO_COMPATIBLE, $this)) { xapp_set_option(Xapp_Rpc_Response_Json::DOJO_COMPATIBLE, xapp_get_option(self::DOJO_COMPATIBLE, $this), $response); } $response = null; $params = null; }
/** * xapp option shortcut xapp_reset_option reset an option value making sure that in case when xapp option handling is * used arrays are fully resetet and not merged when setting options the xapp option functionality. the third parameter * can be: * 1) array = setting $key to $mixed * 2) object = object instance implementing xapp option handling or not * 3) string = object class name as string to handle static classes/options * 4) null = null when called inside class for xapp option handling for auto caller determination * * @param null|string $key expects the option key name * @param null|mixed $value expects the option key value * @param null|object|string $mixed expects value according to explanation above * @return void */ function xapp_reset_option($key = null, $value = null, &$mixed = null) { if (is_array($mixed)) { if (xapp_has_option($key, $mixed)) { $mixed[$key] = $value; } } else { if (xapped()) { Xapp::resetOption($key, $value, $mixed); } else { if (is_object($mixed) && xapp_can_options($mixed)) { if (xapp_has_option($key, $mixed)) { $mixed->options[$key] = $value; } } else { if (is_string($mixed) && xapp_can_options($mixed)) { if (xapp_has_option($key, $mixed)) { $mixed::$options[$key] = $value; } } } } } }