$availableErrors = []; foreach (static::$jsonErrorMessages as $const => $message) { if (defined($const)) { $availableErrors[constant($const)] = $message; } } if (isset($availableErrors[$lastError])) { throw new InvalidParamException($availableErrors[$lastError], $lastError); } throw new InvalidParamException('Unknown JSON encoding/decoding error.'); } /** * Pre-processes the data before sending it to `json_encode()`. * @param mixed $data the data to be processed * @param array $expressions collection of JavaScript expressions
if (is_array($json)) { throw new InvalidParamException('Invalid JSON data.'); } elseif ($json === null || $json === '') { return null; } $decode = json_decode((string) $json, $asArray); static::handleJsonError(json_last_error()); return $decode; } /** * Handles [[encode()]] and [[decode()]] errors by throwing exceptions with the respective error message.
$body = $e->getResponse()->getBody()->getContents(); if (strpos($body, 'DOCTYPE html') !== false) { file_put_contents(ROOT_PATH . '/../runtime/logs/exception' . date('YmdHis') . '.txt', $body); } $response_data = Json::decode($body); if ($this->check_for_token) { $this->checkForToken($response_data); } $error = isset($response_data['error']) ? $response_data['error'] : 'Произошла ошибка';
$response_data = $this->getFromCache(); $this->saveToLog('getFromCache', $response_data); if (!isset($response_data)) { $response_data = $this->executeRequest($method, $responseAsArray); $this->saveToLog('executeRequest', $response_data); $this->saveToCache($response_data); } $this->reset();
* @return mixed * @throws HttpException * @throws \GuzzleHttp\Exception\GuzzleException */ public function get($responseAsArray = true) { return $this->execute(self::GET, $responseAsArray); } /** * @param bool $responseAsArray * @return mixed * @throws HttpException
->setHost(Yii::$app->params[UriHelper::WEBSERVICE_REPLICATION]) ->setPath('/api/portal/masterclass/getInfoByCsiId') ->setQuery([ 'csi_id' => $csi_id, 'funnel_subscribe_date_list' => serialize($funnel_subscribe_date_list) ]) ->get(); } public function getPerformanceRecordsByRoomId($room_id) { return $this->request_builder ->setHost(Yii::$app->params[UriHelper::WEBSERVICE_REPLICATION])
if (!hash_equals($cookie_fsd_hash, $fsd_hash)) { $funnel_subscribe_date_list = null; } } $item_info = RequestExecutor::product()->getInfoByCsiId($csi_id, $funnel_subscribe_date_list); if ( $item_info['conference']['type_id'] === Conference::SALE_TYPE && $item_info['conference']['status_id'] === Conference::END_SALE_STATUS ) { throw new BadRequestHttpException("Sale is closed", ErrorCode::SALE_CLOSED);
if (RequestExecutor::product()->getIsPaintingOnline($csi_id)) { return $this->redirect('https://paintingonline.ru/order/create?csi_id=' . strval($csi_id)); } $order_helper = new OrderHelper(); $params = $order_helper->createOrderHelper($csi_id); $params['show_item_email'] = $show_item_email; return $this->render('create', $params); } public function actionCreatePost()
$args = $this->controller->bindActionParams($this, $params); Yii::trace('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::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); if ($result !== null) { $response->data = $result;
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();
require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); $config = require(__DIR__ . '/../config/web.php'); (new yii\web\Application($config))->run();
$_GET = [ 'product_id' => '39666', ];