private static function makeRequest(array $params) { if (!function_exists('curl_version')) { throw new InvalidConfigException('Extension curl not found'); } $params['format'] = 'json'; $result = file_get_contents('https://geocode-maps.yandex.ru/1.x/?apikey=22d2d5ba-281e-4ffe-b6c6-061dc0ef9074&format='.$params['format'].'&geocode='.$params['geocode']); return json_decode($result, true); } }
if (!function_exists('curl_version')) { throw new InvalidConfigException('Extension curl not found'); } $params['format'] = 'json'; $result = file_get_contents('https://geocode-maps.yandex.ru/1.x/?apikey=22d2d5ba-281e-4ffe-b6c6-061dc0ef9074&format='.$params['format'].'&geocode='.$params['geocode']); return json_decode($result, true); } }
public static function findFirst($objectName, array $params = []) { $params['geocode'] = rawurlencode($objectName); // $params['geocode'] = str_replace(' ', '+', $objectName); // $params['geocode'] = $objectName; $result = self::makeRequest($params); if (isset($result['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos'])) { return explode( ' ', $result['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos'] );
<?php $placemark = []; $cities = \common\models\City::getCityList(); foreach (\common\models\Partner::getShortListByCity() as $cityId => $partners) { // \katzz0\yandexmaps\GeoCoder::$protocol = 'https'; $coord = \rent\components\GeoCoder::findFirst($cities[$cityId]); if ($coord) { $placemark[] = new Placemark( new \katzz0\yandexmaps\Point($coord[1], $coord[0]), [ 'balloonContent' => "<a href='" . Url::to(['partners/index', 'city' => $cityId]) . "'> " . $cities[$cityId] . "</a><br>" . join('<br>', $partners), ],
*/ public function renderPhpFile($_file_, $_params_ = []) { ob_start(); ob_implicit_flush(false); extract($_params_, EXTR_OVERWRITE); require($_file_); return ob_get_clean(); } /** * Renders dynamic content returned by the given PHP statements.
$this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /* @var $renderer ViewRenderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $params, $output); } array_pop($this->_viewFiles); $this->context = $oldContext;
* @throws InvalidParamException if the view cannot be resolved or the view file does not exist. * @see renderFile() */ public function render($view, $params = [], $context = null) { $viewFile = $this->findViewFile($view, $context); return $this->renderFile($viewFile, $params, $context); } /** * Finds the view file based on the given view name. * @param string $view the view name or the path alias of the view file. Please refer to [[render()]] * on how to specify this parameter.
* These parameters will not be available in the layout. * @return string the rendering result. * @throws InvalidParamException if the view file or the layout file does not exist. */ public function render($view, $params = []) { $content = $this->getView()->render($view, $params, $this); return $this->renderContent($content); } /** * Renders a static string by applying a layout. * @param string $content the static string being rendered
* @return string вид * Возвращает нужный вид в зависимости типа запроса, удобная проверка для использования PJAX */ public function render($view, $params = []) { $this->view->title = static::$title . ($this->view->title ? ': ' . $this->view->title : ''); return (Yii::$app->request->isAjax) ? parent::renderPartial($view, $params) : parent::render($view, $params); } public function getParam($name, $default = null) { $s_name = static::className() . '.' . $name; $var = Yii::$app->request->get($name, Yii::$app->session->get($s_name, $default)); Yii::$app->session->set($s_name, $var);
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, ], ]; } public function actionIndex() { return $this->render('index'); } public function actionRequestSubmit() { if (!Yii::$app->request->isPost){ return $this->goHome(); }
$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); Yii::$app->controller = $oldController; return $result; } else { $id = $this->getUniqueId(); throw new InvalidRouteException('Unable to resolve the request "' . ($id === '' ? $route : $id . '/' . $route) . '".');
$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();
$classname = 'yii\\' . $this->getType() . '\Application'; /** * @var $application \yii\console\Application | \yii\web\Application */ $application = new $classname($config); return $application->run(); } public function getFilename($path) { return str_replace('/', DS, $this->baseDir . '/' . $path); }
(new Bootstrap( [ 'name'=>'rent', 'type' => Bootstrap::APP_WEB ] ))->run();
$_SERVER = [ 'CONTEXT_DOCUMENT_ROOT' => '/home/rent/public_html/web/rent', 'CONTEXT_PREFIX' => '', 'DOCUMENT_ROOT' => '/home/rent/public_html/web/rent', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'HTTP_ACCEPT' => '*/*', 'HTTP_HOST' => 'can-on-rent.ru', 'HTTP_USER_AGENT' => 'claudebot', 'PATH' => '/bin:/usr/bin', 'QUERY_STRING' => '', 'REDIRECT_STATUS' => '200', 'REMOTE_ADDR' => '52.55.214.236', 'REMOTE_PORT' => '43954', 'REQUEST_METHOD' => 'GET', 'REQUEST_SCHEME' => 'http', 'REQUEST_URI' => '/', 'SCRIPT_FILENAME' => '/home/rent/public_html/web/rent/index.php', 'SCRIPT_NAME' => '/index.php', 'SERVER_ADDR' => '80.78.247.235', 'SERVER_ADMIN' => 'webmaster@can-on-rent.ru', 'SERVER_NAME' => 'can-on-rent.ru', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SIGNATURE' => 'Apache/2.4.18 (Unix) OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 Server at can-on-rent.ru Port 80 ', 'SERVER_SOFTWARE' => 'Apache/2.4.18 (Unix) OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4', 'PHP_SELF' => '/index.php', 'REQUEST_TIME_FLOAT' => 1711619791.5505850315093994140625, 'REQUEST_TIME' => 1711619791, 'argv' => [], 'argc' => 0, 'APP_ENV' => 'auto', 'APP_DEBUG' => 'true', 'DB_HOST' => 'localhost', 'DB_DBNAME' => 'rent_yii3', 'DB_USERNAME' => 'rent_user', 'DB_PASSWORD' => 'rKlVID80', 'MAILER_USEFILETRANSPORT' => 'true', 'BACKEND_REQUEST_COOKIEVALIDATIONKEY' => 'c8Utf9i6MB_ntFUuWBA1bIaM8FsOBfF', 'FRONTEND_REQUEST_COOKIEVALIDATIONKEY' => 'wx4nuBPvvV0MAcWadx9ZJRlj54GH8wwP', 'RENT_REQUEST_COOKIEVALIDATIONKEY' => 'wx4nuBPvvV0MAcWadx9ZJRlj54GH8wwP', 'FRONTEND_WEB' => 'http://mk', 'BACKEND_WEB' => 'http://office.can-on-rent.ru', 'RENT_WEB' => 'http://can-on-rent.ru', 'STATIC_WEB' => 'http://static.can-on-rent.ru', ]; $_ENV = [ 'CONTEXT_DOCUMENT_ROOT' => '/home/rent/public_html/web/rent', 'CONTEXT_PREFIX' => '', 'DOCUMENT_ROOT' => '/home/rent/public_html/web/rent', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'HTTP_ACCEPT' => '*/*', 'HTTP_HOST' => 'can-on-rent.ru', 'HTTP_USER_AGENT' => 'claudebot', 'PATH' => '/bin:/usr/bin', 'QUERY_STRING' => '', 'REDIRECT_STATUS' => '200', 'REMOTE_ADDR' => '52.55.214.236', 'REMOTE_PORT' => '43954', 'REQUEST_METHOD' => 'GET', 'REQUEST_SCHEME' => 'http', 'REQUEST_URI' => '/', 'SCRIPT_FILENAME' => '/home/rent/public_html/web/rent/index.php', 'SCRIPT_NAME' => '/index.php', 'SERVER_ADDR' => '80.78.247.235', 'SERVER_ADMIN' => 'webmaster@can-on-rent.ru', 'SERVER_NAME' => 'can-on-rent.ru', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SIGNATURE' => 'Apache/2.4.18 (Unix) OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 Server at can-on-rent.ru Port 80 ', 'SERVER_SOFTWARE' => 'Apache/2.4.18 (Unix) OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4', 'APP_ENV' => 'auto', 'APP_DEBUG' => 'true', 'DB_HOST' => 'localhost', 'DB_DBNAME' => 'rent_yii3', 'DB_USERNAME' => 'rent_user', 'DB_PASSWORD' => 'rKlVID80', 'MAILER_USEFILETRANSPORT' => 'true', 'BACKEND_REQUEST_COOKIEVALIDATIONKEY' => 'c8Utf9i6MB_ntFUuWBA1bIaM8FsOBfF', 'FRONTEND_REQUEST_COOKIEVALIDATIONKEY' => 'wx4nuBPvvV0MAcWadx9ZJRlj54GH8wwP', 'RENT_REQUEST_COOKIEVALIDATIONKEY' => 'wx4nuBPvvV0MAcWadx9ZJRlj54GH8wwP', 'FRONTEND_WEB' => 'http://mk', 'BACKEND_WEB' => 'http://office.can-on-rent.ru', 'RENT_WEB' => 'http://can-on-rent.ru', 'STATIC_WEB' => 'http://static.can-on-rent.ru', ];