获取JSSDK的配置数组

@param array $APIs
@param bool  $debug
@param bool  $json

@return string|array
974709
public function config(array $APIs, $debug = false, $json = true)
    {
        $signPackage = $this->getSignature();

        $base = [
            'debug' => $debug,
        ];

        $config = array_merge($base, $signPackage, ['jsApiList' => $APIs]);

        return $json ? JSON::encode($config) : $config;
    }
960591
public function setCurlDebugging($debug = true) {
        $this->blocktrailClient->setCurlDebugging($debug);
        $this->dataClient->setCurlDebugging($debug);
    }
1193408
public function export(Endpoint $endpoint, bool $json = false): string
    {
        $schema = $this->compiler->compile($endpoint);

        if ($json) {
            $result = GraphQL::executeQuery($schema, self::INTROSPECTION_QUERY);

            return json_encode($result->toArray(), JSON_PRETTY_PRINT);
        }

        return SchemaPrinter::doPrint($schema);
    }
500357
public function load($bDebug = false, $sOtherPortail = null)
	{
		$sQuery = $this->_prepare();

		if ($bDebug === true) { echo $sQuery;  }

		$aResults = self::connect()->query($sQuery)->fetchAll(\PDO::FETCH_ASSOC);
		$aReturn = array();
		$i = 0;

		foreach ($aResults as $mKey => $aOneResult) {

			if (isset($aOneResult['.FOUND_ROWS()'])) {

				return $aOneResult['.FOUND_ROWS()'];
			}
			else {

				if ($this->_sFromAs) { $sPrefix = $this->_sFromAs.'.'; }
				else { $sPrefix = ''; }

				$aReturn[$i] = Entity::autoLoadEntity($this->_sFrom, $aOneResult, $sPrefix, true, $sOtherPortail);

				foreach ($this->_aJoin as $aJoin) {

					if (count($aJoin) > 0) {

						if ($aJoin['as']) { $sPrefixJoin = $aJoin['as'].'.'; }
						else { $sPrefixJoin = ''; }
 
						$sPropertieName = 'get_'.$aJoin['table'];

						if (method_exists($aReturn[$i], $sPropertieName)) {
						    
						    $sPropertieName = $aJoin['table'].'2';
						    $aReturn[$i]->$sPropertieName = Entity::autoLoadEntity($aJoin['table'], $aOneResult, $sPrefixJoin, true, $sOtherPortail);
						}
						else {
						
						    $aReturn[$i]->$aJoin['table'] = Entity::autoLoadEntity($aJoin['table'], $aOneResult, $sPrefixJoin, true, $sOtherPortail);
						}
					}
				} 

				$i++;
			}
		}

		$this->flush();

		if ($this->_mWhere instanceof Where) { $this->_mWhere->flush(); }

		/**
		 * Trigger on a model to initialize it every time you load each entity
		 */
		if (isset($aReturn[0]) && method_exists($aReturn[0], 'afterFetch')) {
		    
		    foreach ($aReturn as $iKey => $oOne) {
		    
		        $aReturn[$iKey]::afterFetch();
		    }
		}
		
		return $aReturn;
	}
1192601
public function debug($subject = null, $body = null, $request = true, $server = true) {
        // initialize email
        $email = (new Email('debug'))
            ->setTemplate('Unimatrix/Cake.debug')
            ->setLayout('Unimatrix/Cake.debug');

        // get controller and method
        $location = [];
        foreach(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $one) {
            // ignore current function
            if($one['function'] == __FUNCTION__)
                continue;

            // check if private or protected
            $check = new \ReflectionMethod($one['class'], $one['function']);
            if($check->isPrivate() || $check->isProtected()) {
                // @codeCoverageIgnoreStart
                $location[3] = $one['function'];
                continue;
                // @codeCoverageIgnoreEnd
            }

            // set class and function
            $location[1] = str_replace(['Controller', 'App\\\\', 'TestCase\\\\'], null, $one['class']);
            $location[2] = $one['function'];
            break;
        }

        // sort before using
        ksort($location);

        // overwrite locations
        if(isset($location[1])) {
            if($location[1] == 'Unimatrix\Cake\Console\EmailConsoleErrorHandler') $location = ['EmailConsoleErrorHandler'];
            elseif($location[1] == 'Unimatrix\Cake\Error\EmailErrorHandler') $location = ['EmailErrorHandler'];
            elseif($location[1] == 'Unimatrix\Cake\Error\Middleware\EmailErrorHandlerMiddleware') $location = ['EmailErrorHandlerMiddleware'];
            elseif($location[1] == 'Unimatrix\Cake\Test\Component\EmailComponentTest') $location = ['EmailComponentTest'];
        }

        // get brand
        $from = $email->getFrom();
        $brand = reset($from);

        // set subject
        $email->setSubject($brand . ' report: [' . implode('->', $location) . '] ' . $subject);
        $email->setViewVars(['subject' => $email->getSubject()]);

        // body start
        $body = $body == strip_tags($body) ? nl2br($body) : $body;

        // show request
        if($request) {
            if(isset($_POST) && !empty($_POST))
                $body .= Misc::dump($_POST, '$_POST', true);

            if(isset($_GET) && !empty($_GET))
                $body .= Misc::dump($_GET, '$_GET', true);

            if(isset($_COOKIE) && !empty($_COOKIE))
                $body .= Misc::dump($_COOKIE, '$_COOKIE', true);

            if(isset($_SESSION) && !empty($_SESSION))
                $body .= Misc::dump($_SESSION, '$_SESSION', true);
        }

        // show server
        if($server)
            $body .= Misc::dump($_SERVER, '$_SERVER', true);

        // send email
        return $email->send($body);
    }
117981
public function run($debug = false) {
        $this->debug    = $debug;
        $rqMethod       = strtolower($_SERVER ['REQUEST_METHOD']);
        $this->rqMehtod = ucfirst($rqMethod);
        if ($rqMethod != 'Get') {
            Request::getInstance()->addJsonPostBody();
        }
        $this->format = rqst('format', $this->format);
        if (!$this->format) {
            $this->format = 'json';
        }
        $format = $this->format;
        fire('restful\startCall', time(), $format);
        $rtime     = 0;
        $timestamp = rqst('timestamp');
        //时间检测，时差正负5分钟
        if ($timestamp && preg_match('/^2\d\d\d-(1[0-2]|0[1-9])-(0[1-9]|[12]\d|3[01])\s([01][0-9]|2[0-3]):([0-5]\d):([0-5]\d)(\sGMT)?$/', $timestamp)) {
            $timestampx = @strtotime($timestamp);
            if ($timestampx !== false) {
                $rtime = $timestampx;
            }
        }
        $ctime = time();
        if (($rtime + 300) < $ctime || $rtime - 300 > $ctime) {
            $this->httpout(408, 'Request Timeout');//非法请求
        }
        //时间检测结束
        $v   = irqst('v', 1);
        $api = rqst('api');//API
        if (empty($api)) {
            $this->httpout(400, 'Miss API');
        }
        $app_key = rqst('app_key');//APPKEY
        if (empty($app_key)) {
            return $this->generateResult($format, [
                'error' => [
                    'code' => 40000,
                    'msg'  => __('miss app_key@restful')
                ]
            ]);
        }
        $apis = explode('.', $api);
        if (count($apis) != 3) {
            $this->httpout(406, __('Invalid API@restful'));
        }
        $namesapce = $apis[0];
        $module    = App::getModuleById($namesapce);
        if (!$module) {
            $this->httpout(404, __('module not found@restful'));
        }
        $cls = ucfirst($apis[1]) . 'Api';
        $cls = $namesapce . '\\api\\v' . $v . '\\' . $cls;
        if (class_exists($cls) && is_subclass_of($cls, API::class)) {
            /**@var API $clz */
            $clz = new $cls($app_key, $v);
            $ann = new \ReflectionObject($clz);
            $rm  = $this->rqMehtod;
            try {
                if ($rm != 'Get') {
                    $m = $ann->getMethod($apis[2] . $rm);
                } else {
                    $m = $ann->getMethod($apis[2]);
                }
            } catch (\Exception $mre) {
                try {
                    if ($rm != 'Get') {
                        $tmp = $ann->getMethod($apis[2]);
                        if ($tmp) {
                            $this->httpout(405, __('unsupport request methd@restful'));
                        }
                    }
                } catch (\Exception $e) {

                }
                $m = false;
            }
            if (!$m) {
                $this->httpout(404, __('api not found@restful'));
            }

            $params  = [];//请求参数用于签名
            $dparams = [];//调用参数
            $ps      = $m->getParameters();
            /**@var \ReflectionParameter $p */
            foreach ($ps as $p) {
                $name = $p->getName();
                if (rqset($name)) {
                    $dparams[ $name ] = $params[ $name ] = rqst($name);
                } else if ($p->isOptional()) {
                    $dparams[ $name ] = $p->getDefaultValue();
                } else if (isset($_FILES[ $name ])) {
                    $dparams[ $name ] = $_FILES[ $name ];
                } else {
                    return $this->generateResult($format, [
                        'error' => [
                            'code' => 40001,
                            'msg'  => __('Miss param: %s@restful', $name)
                        ]
                    ]);
                }
            }
            $sign_method = rqst('sign_method');
            if ($sign_method != 'md5' && $sign_method != 'sha1' && $sign_method != 'hmac') {
                return $this->generateResult($format, [
                    'error' => [
                        'code' => 40002,
                        'msg'  => __('unsupport sign methd@restful')
                    ]
                ]);
            }

            $appSecret = $this->secretChecker->check($app_key);
            if (!$appSecret) {
                return $this->generateResult($format, [
                    'error' => [
                        'code' => 40003,
                        'msg'  => __('invalid app_key@restful')
                    ]
                ]);
            }
            //签名
            $sign = rqst('sign');
            $args = array_merge($params, [
                'v'           => $v,
                'app_key'     => $app_key,
                'api'         => $api,
                'timestamp'   => $timestamp,
                'sign_method' => $sign_method
            ]);
            //响应格式
            if (rqset('format')) {
                $args['format'] = $format;
            }
            //会话
            $session = rqst('session');
            if (rqset('session')) {
                $args['session'] = $session;
            }
            $allreqs = Request::getInstance()->requests();
            unset($allreqs['sign']);
            if (($extra = array_diff_key($allreqs, $args))) {
                return $this->generateResult($format, [
                    'error' => [
                        'code'   => 40004,
                        'msg'    => __('unknown params@restful'),
                        'params' => array_keys($extra)
                    ]
                ]);
            }
            //开发模式
            $dev = $this->debug;
            if (!$dev) {
                //验签
                $sign1 = $this->signChecker->sign($args, $appSecret, 'sha1', true);
                if ($sign !== $sign1) {
                    return $this->generateResult($format, [
                        'error' => [
                            'code' => 40005,
                            'msg'  => __('invalid sign@restful')
                        ]
                    ]);
                }
            }

            if ($session) {// 启动了session
                (new Session($this->expire))->start($session);
                $clz->sessionId = $session;
            }

            try {
                $this->api = $api;
                fire('restful\callApi', $api, $ctime, $args);
                $clz->setup();
                $rtn = $m->invokeArgs($clz, $dparams);

                return $this->generateResult($format, $rtn);
            } catch (RestException $re) {
                return $this->generateResult($format, [
                    'error' => [
                        'code' => $re->getCode(),
                        'msg'  => $re->getMessage()
                    ]
                ]);
            } catch (HttpException $he) {
                $this->httpout($he->getCode(), $he->getMessage());
            } catch (UnauthorizedException $un) {
                $this->httpout(401);
            } catch (\PDOException $pe) {
                return $this->generateResult($format, [
                    'error' => [
                        'code' => 40006,
                        'msg'  => __('Internal Error - database')
                    ]
                ]);
            } catch (\Exception $e) {
                log_error('[' . $api . '] failed! ' . $e->getMessage() . "\n" . var_export($dparams, true), 'api');

                return $this->generateResult($format, ['error' => ['code' => 40007, 'msg' => $e->getMessage()]]);
            } finally {
                $clz->tearDown();
                fire('restful\endApi', $api, time(), $args);
            }
        }
        // Not Implemented
        $this->httpout(501);

        return null;
    }
1136346
function serializeDebug($charset_encoding='')
		{
			// Tough encoding problem: which internal charset should we assume for debug info?
			// It might contain a copy of raw data received from client, ie with unknown encoding,
			// intermixed with php generated data and user generated data...
			// so we split it: system debug is base 64 encoded,
			// user debug info should be encoded by the end user using the INTERNAL_ENCODING
			$out = '';
			if ($this->debug_info != '')
			{
				$out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n";
			}
			if($GLOBALS['_xmlrpc_debuginfo']!='')
			{

				$out .= "<!-- DEBUG INFO:\n" . xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n-->\n";
				// NB: a better solution MIGHT be to use CDATA, but we need to insert it
				// into return payload AFTER the beginning tag
				//$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . "\n]]>\n";
			}
			return $out;
		}
1032240
public synchronized DebugServer startDebugServer(int port, int maxClients) {
        if (mDebugServer != null) {
            Log.e(TAG, "Debug server has already been started.");
            return mDebugServer;
        }

        mDebugServer = new DebugServer(this, port, maxClients);
        Threads.spawn(mDebugServer);
        return mDebugServer;
    }
986504
function psnGETRequestDEBUG (url, callback) {
	var 
		options = {
			url: url
			,method : 'GET'
			,headers: {
				'Authorization': 'Bearer ' + accessToken
			}
		}
	;
	console.log('GET '+ url)
	request.get(options, function(error, response, body) {
		callback(body)
	})
}
100834
public static function create(array $containerConfig, bool $debug){
        $startedAt  = microtime(true);
        $timeline   = [];

        // Container initialize
        $start              = microtime(true);
        $containerConfig    = static::createContainerConfigList($containerConfig, $debug, $startedAt);
        $containerFactory   = new ContainerFactory();
        $end                = microtime(true);

        $timeline["container.initialize"]   = [$start, $end];

        // Create container
        $start      = microtime(true);
        $container  = $containerFactory->createWithConfig($containerConfig, true);
        $end        = microtime(true);

        $timeline["container.create"]  = [$start, $end];

        // Create Application
        // コンテナのmodifyでappを触っているとすごく速くなる
        $start  = microtime(true);
        $app    = $container->get("app");
        $end    = microtime(true);

        $timeline["app.create"]  = [$start, $end];

        if(!($app instanceof static)){
            throw new \LogicException;
        }

        if($debug){
            foreach($timeline as $name => $time){
                $container->get("core.debugbar.performance")->addLine($name, $time[0], $time[1]);
            }
        }

        return $app;
    }
1052010
public function getResponseStructure($success = false, $payload = null, $message = '', $debug = null)
    {
        if (isset($debug)) {
            $data = [
                'success' => $success,
                'message' => $message,
                'payload' => $payload,
                'debug' => $debug
            ];
        } else {
            $data = [
                'success' => $success,
                'message' => $message,
                'payload' => $payload
            ];
        }
        return $data;
    }
1013252
public static function display_debugging_messages($return = false) {
        if (empty(self::$debuggings)) {
            return false;
        }

        $debugstring = '';
        foreach(self::$debuggings as $debug) {
            $debugstring .= 'Debugging: ' . $debug->message . "\n" . trim($debug->from) . "\n";
        }

        if ($return) {
            return $debugstring;
        }
        echo $debugstring;
        return true;
    }
914405
public function setDebug($debug)
    {
        if(!is_resource($debug) && !is_bool($debug))
        {
            return $this;
        }

        $this->options['debug'] = $debug;
        return $this;
    }
1309693
public function config(array $APIs, $debug = false, $beta = false, $json = true)
    {
        $signPackage = $this->signature();

        $base = [
            'debug' => $debug,
            'beta'  => $beta,
        ];
        $config = array_merge($base, $signPackage, ['jsApiList' => $APIs]);

        return $json ? json_encode($config) : $config;
    }
1011166
public function debugSet(array $aData = []) {

		$sConfig = get_called_class();

		static::$_lPoolDataChange[$sConfig][$this->_mID] = $aData;
		static::$_lPoolData[$sConfig][$this->_mID] = $aData;
		$this->_coll()->remove([static::$_mKey => $this->_mID]);
		return $this->_coll()->update(
			[static::$_mKey => $this->_mID],
			$aData,
			['upsert' => TRUE]
		);
	}
1097361
public static function fromJson($json, int $options = 0)
    {
        $result = json_decode($json, true, 512, $options);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonDecodeException(json_last_error_msg());
        }

        return new static(\is_array($result) ? $result : []);
    }
495365
public function fetchJson($parameters = [])
    {
        if (!isset($parameters['url'])) {
            Craft::error('URL parameter not set', __METHOD__);
            return false;
        }

        $data = self::getUrl($parameters['url']);
        return json_decode($data, true);
    }