Skip to content

Commit

Permalink
Update SubsiteFluentDirectorInjector.php
Browse files Browse the repository at this point in the history
  • Loading branch information
chromos33 authored Dec 10, 2020
1 parent e263906 commit 3ef0131
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Extensions/SubsiteFluentDirectorInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public function updateRules(&$rules)
Injector::inst()->create(InitStateMiddleware::class)->process($request, function () {
});
$defaultLocale = null;
$host = Convert::raw2sql($_SERVER["HTTP_HOST"]);
if(class_exists("\SilverStripe\Subsites\Model\SubsiteDomain") && array_key_exists("HTTP_HOST",$_SERVER) && !$this->AdminAddressInSERVER())
{
try{
$host = Convert::raw2sql($_SERVER["HTTP_HOST"]);

//Maybe rewrite to SQL Request to reduce performance hit further
//$subsiteDomain = \SilverStripe\Subsites\Model\SubsiteDomain::get()->filter("Domain",$host)->exclude("Locale","")->first();
$subsiteDomain = DB::query("SELECT sd.Locale From SubsiteDomain sd WHERE sd.Domain = '".$host."' AND sd.Locale != ''")->value();
Expand All @@ -59,7 +60,7 @@ public function updateRules(&$rules)
}
if(!$defaultLocale)
{
$defaultLocale = Locale::getDefault(true);
$defaultLocale = Locale::getDefault($host);
if (!$defaultLocale) {
return;
}
Expand Down

0 comments on commit 3ef0131

Please sign in to comment.