Skip to content

Commit

Permalink
Merge fb0e4b2 into dda55d7
Browse files Browse the repository at this point in the history
  • Loading branch information
xerc committed May 13, 2021
2 parents dda55d7 + fb0e4b2 commit 7009155
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions src/Aimeos/Shop/Base/Locale.php
Expand Up @@ -10,10 +10,6 @@
namespace Aimeos\Shop\Base;


use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Route;


/**
* Service providing the context objects
*
Expand All @@ -30,7 +26,7 @@ class Locale
/**
* @var \Aimeos\MShop\Locale\Item\Iface
*/
private $locale;
private $locale = null;


/**
Expand All @@ -52,31 +48,28 @@ public function __construct( \Illuminate\Contracts\Config\Repository $config )
*/
public function get( \Aimeos\MShop\Context\Item\Iface $context ) : \Aimeos\MShop\Locale\Item\Iface
{
if( $this->locale === null )
{
$site = Request::input( 'site', 'default' );
$lang = Request::input( 'locale', app()->getLocale() );
$currency = Request::input( 'currency', '' );

if( Route::current() )
{
$site = Request::route( 'site', $site );
$lang = Request::route( 'locale', $lang );
$currency = Request::route( 'currency', $currency );
}

$localeManager = \Aimeos\MShop::create( $context, 'locale' );
$disableSites = $this->config->get( 'shop.disableSites', true );

$this->locale = $localeManager->bootstrap( $site, $lang, $currency, $disableSites );
if( null !== $this->locale ) {
return $this->locale;
}

if(app()->runningInConsole()) {
$site = 'default';
} else {
$site = request()->getHost();
}

return $this->locale;
$language = app()->getLocale();
$currency = '';// TODO

$localeManager = \Aimeos\MShop::create( $context, 'locale' );
$disableSites = $this->config->get( 'shop.disableSites', true );

return ($this->locale = $localeManager->bootstrap( $site, $language, $currency, $disableSites ));
}


/**
* Returns the locale item for the current request
* Returns the locale item for the stated domain
*
* @param \Aimeos\MShop\Context\Item\Iface $context Context object
* @param string $site Unique site code
Expand Down

0 comments on commit 7009155

Please sign in to comment.