Issues (153)

Classes/Base/Locale.php (2 issues)

Labels
Severity
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;
0 ignored issues
show
The type TYPO3\CMS\Core\Utility\GeneralUtility was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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);
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 said class. However, the method does not exist in Aimeos\MShop\Common\Manager\Decorator\Iface or Aimeos\MShop\Order\Manag...rvice\Transaction\Iface or Aimeos\MShop\Service\Manager\Lists\Type\Iface or Aimeos\MShop\Price\Manager\Iface or Aimeos\MShop\Attribute\Manager\Type\Iface or Aimeos\MShop\Order\Manager\Service\Iface or Aimeos\MShop\Review\Manager\Iface or Aimeos\MShop\Price\Manager\Lists\Type\Iface or Aimeos\MShop\Media\Manager\Type\Iface or Aimeos\MShop\Coupon\Manager\Code\Iface or Aimeos\MShop\Product\Manager\Iface or Aimeos\MShop\Supplier\Manager\Iface or Aimeos\MShop\Price\Manager\Property\Type\Iface or Aimeos\MShop\Common\Manager\Property\Iface or Aimeos\MShop\Customer\Manager\Property\Iface or Aimeos\MShop\Price\Manager\Lists\Iface or Aimeos\MShop\Supplier\Manager\Lists\Type\Iface or Aimeos\MShop\Service\Manager\Lists\Iface or Aimeos\MShop\Tag\Manager\Type\Iface or Aimeos\MShop\Text\Manager\Lists\Iface or Aimeos\MShop\Price\Manager\Type\Iface or Aimeos\MShop\Locale\Manager\Currency\Iface or Aimeos\MShop\Media\Manager\Lists\Type\Iface or Aimeos\MShop\Catalog\Manager\Lists\Iface or Aimeos\MShop\Tag\Manager\Iface or Aimeos\MShop\Coupon\Manager\Iface or Aimeos\MShop\Attribute\Manager\Iface or Aimeos\MShop\Common\Manager\Lists\Iface or Aimeos\MShop\Attribute\Manager\Property\Type\Iface or Aimeos\MShop\Service\Manager\Type\Iface or Aimeos\MShop\Order\Manager\Address\Iface or Aimeos\MShop\Product\Manager\Lists\Iface or Aimeos\MShop\Order\Manager\Product\Attribute\Iface or Aimeos\MShop\Customer\Manager\Property\Type\Iface or Aimeos\MShop\Order\Manager\Iface or Aimeos\MShop\Customer\Manager\Iface or Aimeos\MShop\Media\Manager\Iface or Aimeos\MShop\Rule\Manager\Type\Iface or Aimeos\MShop\Order\Manager\Coupon\Iface or Aimeos\MShop\Customer\Manager\Lists\Type\Iface or Aimeos\MShop\Attribute\Manager\Lists\Iface or Aimeos\MShop\Product\Manager\Property\Type\Iface or Aimeos\MShop\Media\Manager\Lists\Iface or Aimeos\MShop\Plugin\Manager\Iface or Aimeos\MShop\Catalog\Manager\Iface or Aimeos\MShop\Locale\Manager\Site\Iface or Aimeos\MShop\Order\Manager\Service\Attribute\Iface or Aimeos\MShop\Product\Manager\Type\Iface or Aimeos\MShop\Supplier\Manager\Lists\Iface or Aimeos\MShop\Stock\Manager\Type\Iface or Aimeos\MShop\Text\Manager\Iface or Aimeos\MShop\Common\Manager\Type\Iface or Aimeos\MAdmin\Job\Manager\Iface or Aimeos\MShop\Customer\Manager\Group\Iface or Aimeos\MShop\Product\Manager\Lists\Type\Iface or Aimeos\MShop\Text\Manager\Lists\Type\Iface or Aimeos\MShop\Text\Manager\Type\Iface or Aimeos\MShop\Order\Manager\Status\Iface or Aimeos\MShop\Rule\Manager\Iface or Aimeos\MShop\Common\Manager\Address\Iface or Aimeos\MShop\Plugin\Manager\Type\Iface or Aimeos\MShop\Stock\Manager\Iface or Aimeos\MShop\Attribute\Manager\Property\Iface or Aimeos\MShop\Subscription\Manager\Iface or Aimeos\MShop\Media\Manager\Property\Type\Iface or Aimeos\MShop\Product\Manager\Property\Iface or Aimeos\MShop\Locale\Manager\Language\Iface or Aimeos\MShop\Media\Manager\Property\Iface or Aimeos\MShop\Service\Manager\Iface or Aimeos\MShop\Attribute\Manager\Lists\Type\Iface or Aimeos\MAdmin\Log\Manager\Iface or Aimeos\MAdmin\Cache\Manager\Iface or Aimeos\MShop\Order\Manager\Basket\Iface or Aimeos\MShop\Order\Manager\Product\Iface or Aimeos\MShop\Price\Manager\Property\Iface or Aimeos\MShop\Customer\Manager\Lists\Iface or Aimeos\MShop\Catalog\Manager\Lists\Type\Iface or Aimeos\MShop\Index\Manager\Iface or Aimeos\MShop\Index\Manager\Attribute\Iface or Aimeos\MShop\Index\Manager\Text\Iface or Aimeos\MShop\Index\Manager\Supplier\Iface or Aimeos\MShop\Index\Manager\Catalog\Iface or Aimeos\MShop\Index\Manager\Price\Iface or Aimeos\MShop\Supplier\Manager\Address\Iface or Aimeos\MShop\Customer\Manager\Address\Iface. Are you sure you never get one of those? ( 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
            self::$locale = $localeManager->bootstrap($sitecode, $lang, $currency);
Loading history...
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