Skip to content

Commit 5480c23

Browse files
update domains
1 parent 09273b6 commit 5480c23

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/CmsSeoComponent.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@
2929
use yii\widgets\ListView;
3030

3131
/**
32+
*
33+
* 'seo' => [
34+
'canUrl' => [
35+
'scheme' => 'https',
36+
'host' => 'skeeks-travel.ru',
37+
],
38+
],
39+
*
40+
* 'seo' => [
41+
'canUrl' => [
42+
'scheme' => CmsSeoComponent::CANURL_DATA_FROM_MAIN_DOMAIN,
43+
'host' => CmsSeoComponent::CANURL_DATA_FROM_MAIN_DOMAIN,
44+
],
45+
],
46+
*
3247
* @property CanUrl $canUrl;
3348
* @property array $utms;
3449
*
@@ -41,6 +56,11 @@ class CmsSeoComponent extends Component implements BootstrapInterface
4156
*/
4257
const SESSION_SEO_REQUEST_UTMS = 'session_seo_request_utms';
4358

59+
/**
60+
*
61+
*/
62+
const CANURL_DATA_FROM_MAIN_DOMAIN = '_can_url_from_main_domain';
63+
4464
/**
4565
* Максимадбгая длина ключевых слов
4666
* @var int
@@ -418,17 +438,34 @@ protected function _initDefaultCanUrl()
418438
/**
419439
* Хост может быть не указан, тогда будет взят из запроса
420440
*/
441+
if ($this->canUrl->host == self::CANURL_DATA_FROM_MAIN_DOMAIN) {
442+
if (\Yii::$app->cms->site && \Yii::$app->cms->site->cmsSiteMainDomain) {
443+
$this->canUrl->host = \Yii::$app->cms->site->cmsSiteMainDomain->domain;
444+
} else {
445+
$this->canUrl->host = null;
446+
}
447+
}
448+
421449
if (!$this->canUrl->host) {
422450
$this->canUrl->host = \Yii::$app->request->hostName;
423451
}
424452

425453
/**
426454
* Аналогично со схемой
427455
*/
456+
if ($this->canUrl->scheme == self::CANURL_DATA_FROM_MAIN_DOMAIN) {
457+
if (\Yii::$app->cms->site && \Yii::$app->cms->site->cmsSiteMainDomain) {
458+
$this->canUrl->scheme = \Yii::$app->cms->site->cmsSiteMainDomain->is_https ? "https" : "http";
459+
} else {
460+
$this->canUrl->scheme = null;
461+
}
462+
}
463+
428464
if (!$this->canUrl->scheme) {
429465
$this->canUrl->scheme = \Yii::$app->request->isSecureConnection ? "https" : "http";
430466
}
431467

468+
432469
if (\Yii::$app->requestedRoute) {
433470
$requestedUrl = Url::to(ArrayHelper::merge(["/".\Yii::$app->requestedRoute],
434471
(array)\Yii::$app->request->queryParams));

0 commit comments

Comments
 (0)