1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license GPLv3, http://www.gnu.org/copyleft/gpl.html |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016 |
6
|
|
|
* @package TYPO3 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Aimeos\Base; |
11
|
|
|
|
12
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
|
|
|
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Aimeos locale class |
17
|
|
|
* |
18
|
|
|
* @package TYPO3 |
19
|
|
|
*/ |
20
|
|
|
class Locale |
21
|
|
|
{ |
22
|
|
|
private static $locale; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Returns the locale object for frontend |
27
|
|
|
* |
28
|
|
|
* @param \Aimeos\MShop\ContextIface $context Context object |
29
|
|
|
* @param \TYPO3\CMS\Extbase\Mvc\RequestInterface|null $request Request object |
30
|
|
|
* @return \Aimeos\MShop\Locale\Item\Iface Locale item object |
31
|
|
|
*/ |
32
|
|
|
public static function get(\Aimeos\MShop\ContextIface $context, |
33
|
|
|
\TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null) : \Aimeos\MShop\Locale\Item\Iface |
34
|
|
|
{ |
35
|
|
|
if (!isset(self::$locale)) { |
36
|
|
|
$config = $context->config(); |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
$sitecode = $config->get('mshop/locale/site', 'default'); |
40
|
|
|
$name = $config->get('typo3/param/name/site', 'site'); |
41
|
|
|
|
42
|
|
|
if ($request !== null && $request->hasArgument($name) === true) { |
43
|
|
|
$sitecode = $request->getArgument($name); |
44
|
|
|
} elseif (($value = GeneralUtility::_GP('S')) !== null) { |
45
|
|
|
$sitecode = $value; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
$lang = $config->get('mshop/locale/language', ''); |
50
|
|
|
$name = $config->get('typo3/param/name/language', 'locale'); |
51
|
|
|
|
52
|
|
|
if ($request !== null && $request->hasArgument($name) === true) { |
53
|
|
|
$lang = $request->getArgument($name); |
54
|
|
|
} elseif (isset($GLOBALS['TSFE']->id)) { // TYPO3 9+ |
55
|
|
|
$langid = GeneralUtility::makeInstance('TYPO3\CMS\Core\Context\Context')->getAspect('language')->getId(); |
56
|
|
|
$site = GeneralUtility::makeInstance('TYPO3\CMS\Core\Site\SiteFinder')->getSiteByPageId($GLOBALS['TSFE']->id); |
57
|
|
|
$lang = substr($site->getLanguageById($langid)->getLocale(), 0, 5); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
$currency = $config->get('mshop/locale/currency', ''); |
62
|
|
|
$name = $config->get('typo3/param/name/currency', 'currency'); |
63
|
|
|
|
64
|
|
|
if ($request !== null && $request->hasArgument($name) === true) { |
65
|
|
|
$currency = $request->getArgument($name); |
66
|
|
|
} elseif (($value = GeneralUtility::_GP('C')) !== null) { |
67
|
|
|
$currency = $value; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
$localeManager = \Aimeos\MShop::create($context, 'locale'); |
72
|
|
|
self::$locale = $localeManager->bootstrap($sitecode, $lang, $currency); |
|
|
|
|
73
|
|
|
|
74
|
|
|
$config->apply(self::$locale->getSiteItem()->getConfig()); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
return self::$locale; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Returns the locale item for the backend |
83
|
|
|
* |
84
|
|
|
* @param \Aimeos\MShop\ContextIface $context Context object |
85
|
|
|
* @param string $site Unique site code |
86
|
|
|
* @return \Aimeos\MShop\ContextIface Modified context object |
87
|
|
|
*/ |
88
|
|
|
public static function getBackend(\Aimeos\MShop\ContextIface $context, string $site) : \Aimeos\MShop\Locale\Item\Iface |
89
|
|
|
{ |
90
|
|
|
$localeManager = \Aimeos\MShop::create($context, 'locale'); |
91
|
|
|
|
92
|
|
|
try { |
93
|
|
|
$localeItem = $localeManager->bootstrap($site, '', '', false, null, true); |
94
|
|
|
$context->config()->apply($localeItem->getSiteItem()->getConfig()); |
95
|
|
|
} catch(\Aimeos\MShop\Exception $e) { |
96
|
|
|
$localeItem = $localeManager->create(); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return $localeItem->setCurrencyId(null)->setLanguageId(null); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths