$response->getReasonPhrase() ); $summary = static::getResponseBodySummary($response); if ($summary !== null) { $message .= ":\n{$summary}\n"; } return new $className($message, $request, $response, $previous, $ctx); } /** * Get a short summary of the response * * Will return `null` if the response is not printable. * * @param ResponseInterface $response *
return $handler($request, $options)->then( function (ResponseInterface $response) use ($request) { $code = $response->getStatusCode(); if ($code < 400) { return $response; } throw RequestException::create($request, $response); } ); }; }; }
if ($promise->getState() !== self::PENDING) { return; } try { if (isset($handler[$index])) { $promise->resolve($handler[$index]($value)); } elseif ($index === 1) { // Forward resolution values as-is. $promise->resolve($value); } else { // Forward rejections down the chain. $promise->reject($value);
// it in the task queue using the correct ID. if (!method_exists($value, 'then')) { $id = $state === self::FULFILLED ? 1 : 2; // It's a success, so resolve the handlers in the queue. queue()->add(static function () use ($id, $value, $handlers) { foreach ($handlers as $handler) { self::callHandler($id, $value, $handler); } }); } elseif ($value instanceof Promise && $value->getState() === self::PENDING ) { // We can just merge our handlers onto the next promise.
} public function run() { /** @var callable $task */ while ($task = array_shift($this->queue)) { $task(); } } /** * The task queue will be run and exhausted by default when the process * exits IFF the exit is not the result of a PHP E_ERROR error.
private function invokeWaitFn() { try { $wfn = $this->waitFn; $this->waitFn = null; $wfn(true); } catch (\Exception $reason) { if ($this->state === self::PENDING) { // The promise has not been resolved yet, so reject the promise // with the exception. $this->reject($reason); } else {
private function waitIfPending() { if ($this->state !== self::PENDING) { return; } elseif ($this->waitFn) { $this->invokeWaitFn(); } elseif ($this->waitList) { $this->invokeWaitList(); } else { // If there's not wait function, then reject the promise. $this->reject('Cannot wait on a promise that has ' . 'no internal wait function. You must provide a wait '
{ $waitList = $this->waitList; $this->waitList = null; foreach ($waitList as $result) { while (true) { $result->waitIfPending(); if ($result->result instanceof Promise) { $result = $result->result; } else { if ($result->result instanceof PromiseInterface) { $result->result->wait(false);
{ if ($this->state !== self::PENDING) { return; } elseif ($this->waitFn) { $this->invokeWaitFn(); } elseif ($this->waitList) { $this->invokeWaitList(); } else { // If there's not wait function, then reject the promise. $this->reject('Cannot wait on a promise that has ' . 'no internal wait function. You must provide a wait ' . 'function when constructing the promise to be able to ' . 'wait on a promise.');
{ return $this->then(null, $onRejected); } public function wait($unwrap = true) { $this->waitIfPending(); $inner = $this->result instanceof PromiseInterface ? $this->result->wait($unwrap) : $this->result; if ($unwrap) {
* @return ResponseInterface * @throws GuzzleException */ public function request($method, $uri = '', array $options = []) { $options[RequestOptions::SYNCHRONOUS] = true; return $this->requestAsync($method, $uri, $options)->wait(); } /** * Get a client configuration option. * * These options include default request options of the client, a "handler"
$uri = $args[0]; $opts = isset($args[1]) ? $args[1] : []; return substr($method, -5) === 'Async' ? $this->requestAsync(substr($method, 0, -5), $uri, $opts) : $this->request($method, $uri, $opts); } /** * Asynchronously send an HTTP request. * * @param array $options Request options to apply to the given
return json_decode((new Client())->get('https://api.aimapa.com/companies/kved/'.$section.'/paged')->getBody()); //return json_decode((new Client())->get('https://api.aimapa.com/companies/paged?section='.$section)->getBody()); } public function getInitialCompanies() { return json_decode((new Client())->get('https://api.aimapa.com/companies/paged?sorted=true')->getBody()); } public function getCompaniesByName($q) { $client = new Client(); $request = 'https://api.aimapa.com/companies/paged?name='.url_encode($q);
} public function getBubblesData($section = null) { $data = []; if(empty($section)) { $companies = $this->getInitialCompanies(); } else { $companies = $this->getCompaniesBySection($section); } if(empty($companies->companies)) { return 'false'; } else {
$this->layout = '/../../views/layouts/main_new.php'; if(!Yii::$app->user->isGuest) { return $this->redirect(Url::to(['market-analytic'])); } return $this->render('intro', [ 'kvedSections' => $this->service->getKvedSections(), 'bubblesData' => $this->service->getBubblesData() ]); } public function actionMarketAnalytic() { $this->layout = '/../../views/layouts/client-layout.php';
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
#try{ # (new yii\web\Application($config))->run(); #} catch (\yii\web\HeadersAlreadySentException $headersExeption) { #}catch (\Exception $e){ echo ($e->getMessage()); die(); # } (new yii\web\Application($config))->run();
$_SESSION = [ '__flash' => [], 'language' => 'en', ];