Issues (68)

src/Aimeos/Shop/Base/Locale.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package laravel
7
 * @subpackage Base
8
 */
9
10
namespace Aimeos\Shop\Base;
11
12
13
use Illuminate\Support\Facades\Request;
14
use Illuminate\Support\Facades\Route;
15
16
17
/**
18
 * Service providing the context objects
19
 *
20
 * @package laravel
21
 * @subpackage Base
22
 */
23
class Locale
24
{
25
	/**
26
	 * @var \Illuminate\Contracts\Config\Repository
27
	 */
28
	private $config;
29
30
	/**
31
	 * @var \Aimeos\MShop\Locale\Item\Iface
32
	 */
33
	private $locale;
34
35
36
	/**
37
	 * Initializes the object
38
	 *
39
	 * @param \Illuminate\Contracts\Config\Repository $config Configuration object
40
	 */
41
	public function __construct( \Illuminate\Contracts\Config\Repository $config )
42
	{
43
		$this->config = $config;
44
	}
45
46
47
	/**
48
	 * Returns the locale item for the current request
49
	 *
50
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
51
	 * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
52
	 */
53
	public function get( \Aimeos\MShop\Context\Item\Iface $context )
54
	{
55
		if( $this->locale === null )
56
		{
57
			$site = Request::get( 'site', 'default' );
58
			$currency = Request::get( 'currency', '' );
59
			$lang = Request::get( 'locale', '' );
60
61
			if( Route::current() )
62
			{
63
				$site =  Route::input( 'site', $site );
64
				$currency = Route::input( 'currency', $currency );
65
				$lang = Route::input( 'locale', $lang );
66
			}
67
68
			$localeManager = \Aimeos\MShop::create( $context, 'locale' );
69
			$disableSites = $this->config->get( 'shop.disableSites', true );
70
71
			try {
72
				$this->locale = $localeManager->bootstrap( $site, $lang, $currency, $disableSites );
0 ignored issues
show
The method bootstrap() does not exist on Aimeos\MShop\Common\Manager\Iface. It seems like you code against a sub-type of Aimeos\MShop\Common\Manager\Iface such as Aimeos\MShop\Locale\Manager\Iface or Aimeos\MShop\Common\Manager\Decorator\Base or Aimeos\MShop\Service\Manager\Lists\Type\Standard or Aimeos\MShop\Price\Manager\Standard or Aimeos\MShop\Attribute\Manager\Type\Standard or Aimeos\MShop\Price\Manager\Lists\Type\Standard or Aimeos\MShop\Media\Manager\Type\Standard or Aimeos\MShop\Coupon\Manager\Code\Standard or Aimeos\MShop\Order\Manager\Base\Coupon\Standard or Aimeos\MShop\Index\Manager\DBBase or Aimeos\MShop\Product\Manager\Standard or Aimeos\MShop\Index\Manager\Standard or Aimeos\MShop\Index\Manager\Attribute\Standard or Aimeos\MShop\Index\Manager\Text\Standard or Aimeos\MShop\Index\Manager\Supplier\Standard or Aimeos\MShop\Index\Manager\Catalog\Standard or Aimeos\MShop\Index\Manager\Price\Standard or Aimeos\MShop\Supplier\Manager\Standard or Aimeos\MShop\Price\Manager\Property\Type\Standard or Aimeos\MShop\Customer\Manager\Property\Standard or Aimeos\MShop\Order\Manager\Base\Service\Standard or Aimeos\MShop\Order\Manager\Base\Standard or Aimeos\MShop\Price\Manager\Lists\Standard or Aimeos\MShop\Supplier\Manager\Lists\Type\Standard or Aimeos\MShop\Order\Manag...vice\Attribute\Standard or Aimeos\MShop\Service\Manager\Lists\Standard or Aimeos\MShop\Tag\Manager\Type\Standard or Aimeos\MShop\Text\Manager\Lists\Standard or Aimeos\MShop\Price\Manager\Type\Standard or Aimeos\MShop\Locale\Manager\Currency\Standard or Aimeos\MShop\Order\Manag...duct\Attribute\Standard or Aimeos\MShop\Media\Manager\Lists\Type\Standard or Aimeos\MShop\Catalog\Manager\Lists\Standard or Aimeos\MShop\Tag\Manager\Standard or Aimeos\MShop\Coupon\Manager\Standard or Aimeos\MShop\Attribute\Manager\Standard or Aimeos\MShop\Attribute\M...\Property\Type\Standard or Aimeos\MShop\Service\Manager\Type\Standard or Aimeos\MShop\Product\Manager\Lists\Standard or Aimeos\MShop\Customer\Ma...\Property\Type\Standard or Aimeos\MShop\Order\Manager\Standard or Aimeos\MShop\Customer\Manager\Standard or Aimeos\MShop\Media\Manager\Standard or Aimeos\MShop\Customer\Manager\Lists\Type\Standard or Aimeos\MShop\Attribute\Manager\Lists\Standard or Aimeos\MShop\Product\Man...\Property\Type\Standard or Aimeos\MShop\Media\Manager\Lists\Standard or Aimeos\MShop\Plugin\Manager\Standard or Aimeos\MShop\Order\Manager\Base\Address\Standard or Aimeos\MShop\Catalog\Manager\Standard or Aimeos\MShop\Locale\Manager\Site\Standard or Aimeos\MShop\Product\Manager\Type\Standard or Aimeos\MShop\Supplier\Manager\Lists\Standard or Aimeos\MShop\Stock\Manager\Type\Standard or Aimeos\MShop\Text\Manager\Standard or Aimeos\MAdmin\Job\Manager\Standard or Aimeos\MShop\Customer\Manager\Group\Standard or Aimeos\MShop\Product\Manager\Lists\Type\Standard or Aimeos\MShop\Text\Manager\Lists\Type\Standard or Aimeos\MShop\Text\Manager\Type\Standard or Aimeos\MShop\Order\Manager\Status\Standard or Aimeos\MShop\Supplier\Manager\Address\Standard or Aimeos\MShop\Customer\Manager\Address\Standard or Aimeos\MShop\Plugin\Manager\Type\Standard or Aimeos\MShop\Stock\Manager\Standard or Aimeos\MShop\Stock\Manager\Nolimit or Aimeos\MShop\Attribute\Manager\Property\Standard or Aimeos\MShop\Subscription\Manager\Standard or Aimeos\MShop\Media\Manager\Property\Type\Standard or Aimeos\MShop\Product\Manager\Property\Standard or Aimeos\MShop\Locale\Manager\Language\Standard or Aimeos\MShop\Media\Manager\Property\Standard or Aimeos\MShop\Service\Manager\Standard or Aimeos\MShop\Attribute\Manager\Lists\Type\Standard or Aimeos\MAdmin\Log\Manager\Standard or Aimeos\MAdmin\Cache\Manager\Standard or Aimeos\MAdmin\Cache\Manager\None or Aimeos\MShop\Order\Manager\Base\Product\Standard or Aimeos\MShop\Price\Manager\Property\Standard or Aimeos\MShop\Customer\Manager\Lists\Standard or Aimeos\MShop\Catalog\Manager\Lists\Type\Standard. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

72
				/** @scrutinizer ignore-call */ 
73
    $this->locale = $localeManager->bootstrap( $site, $lang, $currency, $disableSites );
Loading history...
73
			} catch( \Aimeos\MShop\Locale\Exception $e ) {
74
				$this->locale = $localeManager->bootstrap( 'default', $lang, $currency, $disableSites );
75
			}
76
		}
77
78
		return $this->locale;
79
	}
80
81
82
	/**
83
	 * Returns the locale item for the current request
84
	 *
85
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
86
	 * @param string $site Unique site code
87
	 * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
88
	 */
89
	public function getBackend( \Aimeos\MShop\Context\Item\Iface $context, $site )
90
	{
91
		$localeManager = \Aimeos\MShop::create( $context, 'locale' );
92
93
		try {
94
			$localeItem = $localeManager->bootstrap( $site, '', '', false, null, true );
95
		} catch( \Aimeos\MShop\Exception $e ) {
96
			$localeItem = $localeManager->createItem();
97
		}
98
99
		return $localeItem->setCurrencyId( null )->setLanguageId( null );
100
	}
101
}
102