public static function getTextForServicesInCity(City $city, ExcSearch $searchModel): array { $title_string = $city->exc_title ?: 'Экскурсии в {city-prep} ({country}) {season} на русском языке: цены, отзывы'; $description_string = $city->exc_description ?: 'Индивидуальные и групповые экскурсии в {city-prep} ({country}) в {season} году на русском языке. Каталог туристических экскурсий в {city-prep} от местных гидов стоимость от {min-price} в {city-prep}. Бронирование онлайн!'; $city_name_prep = Yii::$app->inflection->inflectGeoName($city->name, Inflector::PREPOSITIONAL); $country_name = $city->country->name; $season = date('Y') . '-' . date('Y', strtotime('+1 year')); $first_exc = $searchModel->getBestPrice()->getModels()[0]; $min_esc_price = $first_exc->getPriceForSeo(); // $min_esc_price = $searchModel->getBestPrice()->getModels()[0]->getPriceForSeo(); $page_title = str_replace(['{city-prep}', '{country}', '{season}'], [$city_name_prep, $country_name, $season], $title_string) . self::setNumPage()['title']; $page_description = str_replace(['{city-prep}', '{country}', '{season}', '{min-price}'], [$city_name_prep, $country_name, $season, $min_esc_price], $description_string) . self::setNumPage()['description']; return [ 'title' => $page_title, 'description' => $page_description, ];
* @param \frontend\modules\excursions\models\ExcSearch $searchModel */ public function setServicesMetaTagsForCity(City $city, ExcSearch $searchModel) : void { $view = Yii::$app->view; $og_image = Yii::$app->getRequest()->getHostInfo() . '/images/tselector-og.png'; $meta_data = MetaTextHelper::getTextForServicesInCity($city, $searchModel); $view->title = $meta_data['title']; $view->registerMetaTag(['name' => 'description', 'content' => $meta_data['description']]); $this->setOpenGraphTags($view->title, $meta_data['description'], $og_image); } /**
if (!$excursions->count && Yii::$app->request->get('page')) { throw new NotFoundHttpException('The requested page does not exist.'); } error_reporting("E_WARNING"); if ($city_obj) { Yii::$app->seo->setServicesMetaTagsForCity($city_obj, $searchModel); Yii::$app->schemaOrg->pageListServicesInCity($city_obj, $searchModel, $excursions); } else { Yii::$app->seo->setServicesMetaTagsForCountry($country_obj, $searchModel); Yii::$app->schemaOrg->pageListServicesInCountry($country_obj, $searchModel, $excursions); }
$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();
require __DIR__ . '/../../common/config/main.php', require __DIR__ . '/../../common/config/main-local.php', require __DIR__ . '/../config/main.php', require __DIR__ . '/../config/main-local.php' ); (new yii\web\Application($config))->run();
$_GET = [ 'country' => 'russia', 'city' => 'samara', ];