From 7092636388d54d5de47011ace9718182feaeae7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alen=20Paga=C4=8D?= Date: Thu, 4 Apr 2019 13:57:24 +0200 Subject: [PATCH 1/6] LDP-97: Method that returns variant url. --- src/RequestMatcher.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/RequestMatcher.php b/src/RequestMatcher.php index 6cd2754..4c8a3b7 100644 --- a/src/RequestMatcher.php +++ b/src/RequestMatcher.php @@ -164,6 +164,24 @@ public static function getSiteVariables($site = NULL) { return $vars; } + /** + * Gets the variant url. + * + * @param string $variant + * Variant name. + * + * @return bool|string + * Variant url or bool if variant incorrect. + */ + public function getHostForSiteVariant($variant) { + if (!in_array($variant, $this->variants)) { + return FALSE; + } + $site = static::determineActiveSite(); + $url = getenv('URL_SCHEME') . '://' . $variant . $this->variantSeparator . $site . $this->multisiteDomainSeparator . $this->multisiteDomain; + return $url; + } + /** * Gets the site variables as string. * From d4e321d6743f4d3d043fb9efa0c412ae60125e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alen=20Paga=C4=8D?= Date: Fri, 5 Apr 2019 10:34:32 +0200 Subject: [PATCH 2/6] LDP-97: Chagned ge thost for variant. --- src/RequestMatcher.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/RequestMatcher.php b/src/RequestMatcher.php index 4c8a3b7..2dc27b1 100644 --- a/src/RequestMatcher.php +++ b/src/RequestMatcher.php @@ -165,21 +165,21 @@ public static function getSiteVariables($site = NULL) { } /** - * Gets the variant url. + * Gets the variant host. * - * @param string $variant + * @param $variant * Variant name. * - * @return bool|string - * Variant url or bool if variant incorrect. + * @return string|null + * Variant url or null if variant incorrect. */ public function getHostForSiteVariant($variant) { if (!in_array($variant, $this->variants)) { - return FALSE; + return NULL; } $site = static::determineActiveSite(); - $url = getenv('URL_SCHEME') . '://' . $variant . $this->variantSeparator . $site . $this->multisiteDomainSeparator . $this->multisiteDomain; - return $url; + $variant_host = $variant . $this->variantSeparator . $site . $this->multisiteDomainSeparator . $this->multisiteDomain; + return $variant_host; } /** From 015ab2e6d690da533e30f47bcd1938c2fd7d5dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alen=20Paga=C4=8D?= Date: Fri, 5 Apr 2019 10:47:37 +0200 Subject: [PATCH 3/6] LDP-97: Prepare url scheme method. --- src/RequestMatcher.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/RequestMatcher.php b/src/RequestMatcher.php index 2dc27b1..b2bb479 100644 --- a/src/RequestMatcher.php +++ b/src/RequestMatcher.php @@ -177,11 +177,24 @@ public function getHostForSiteVariant($variant) { if (!in_array($variant, $this->variants)) { return NULL; } - $site = static::determineActiveSite(); - $variant_host = $variant . $this->variantSeparator . $site . $this->multisiteDomainSeparator . $this->multisiteDomain; + $site_variables = static::getSiteVariables(); + $url_scheme = static::getUrlScheme(); + $variant_host = $url_scheme . $variant . $this->variantSeparator . $site_variables['SITE_HOST']; + return $variant_host; } + /** + * @return string + * Url scheme value from env var. + */ + public static function getUrlScheme() { + if ($url_scheme = getenv('URL_SCHEME')) { + return $url_scheme . "://"; + } + return "//"; + } + /** * Gets the site variables as string. * From 3276568b9f7cc53a218223f48309bae884fbdd87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alen=20Paga=C4=8D?= Date: Fri, 5 Apr 2019 10:54:13 +0200 Subject: [PATCH 4/6] LDP-97: Remvoe url scheme from host method. --- src/RequestMatcher.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/RequestMatcher.php b/src/RequestMatcher.php index b2bb479..dd8f0d6 100644 --- a/src/RequestMatcher.php +++ b/src/RequestMatcher.php @@ -178,8 +178,7 @@ public function getHostForSiteVariant($variant) { return NULL; } $site_variables = static::getSiteVariables(); - $url_scheme = static::getUrlScheme(); - $variant_host = $url_scheme . $variant . $this->variantSeparator . $site_variables['SITE_HOST']; + $variant_host = $variant . $this->variantSeparator . $site_variables['SITE_HOST']; return $variant_host; } From e4d36fd29e80b859e67ec4f85571856c34929ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alen=20Paga=C4=8D?= Date: Fri, 5 Apr 2019 10:56:35 +0200 Subject: [PATCH 5/6] LDP-97: CS fix. --- src/RequestMatcher.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/RequestMatcher.php b/src/RequestMatcher.php index dd8f0d6..c86b649 100644 --- a/src/RequestMatcher.php +++ b/src/RequestMatcher.php @@ -167,7 +167,7 @@ public static function getSiteVariables($site = NULL) { /** * Gets the variant host. * - * @param $variant + * @param string $variant * Variant name. * * @return string|null @@ -184,6 +184,8 @@ public function getHostForSiteVariant($variant) { } /** + * Gets the url scheme. + * * @return string * Url scheme value from env var. */ From 11efad8ace87829e580375770199b24298d0c9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alen=20Paga=C4=8D?= Date: Fri, 5 Apr 2019 15:56:14 +0200 Subject: [PATCH 6/6] LDP-97: Removed fetching url scheme. Comment fix. Use main host. --- src/RequestMatcher.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/RequestMatcher.php b/src/RequestMatcher.php index c86b649..9e0cf3e 100644 --- a/src/RequestMatcher.php +++ b/src/RequestMatcher.php @@ -171,31 +171,18 @@ public static function getSiteVariables($site = NULL) { * Variant name. * * @return string|null - * Variant url or null if variant incorrect. + * Variant hostname or null if variant incorrect. */ public function getHostForSiteVariant($variant) { if (!in_array($variant, $this->variants)) { return NULL; } $site_variables = static::getSiteVariables(); - $variant_host = $variant . $this->variantSeparator . $site_variables['SITE_HOST']; + $variant_host = $variant . $this->variantSeparator . $site_variables['SITE_MAIN_HOST']; return $variant_host; } - /** - * Gets the url scheme. - * - * @return string - * Url scheme value from env var. - */ - public static function getUrlScheme() { - if ($url_scheme = getenv('URL_SCHEME')) { - return $url_scheme . "://"; - } - return "//"; - } - /** * Gets the site variables as string. *