123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Braintree\Model;
- use Magento\Framework\Locale\ResolverInterface;
- use Magento\Braintree\Gateway\Config\PayPal\Config;
- class LocaleResolver implements ResolverInterface
- {
- /**
- * @var ResolverInterface
- */
- private $resolver;
- /**
- * @var Config
- */
- private $config;
- /**
- * @param ResolverInterface $resolver
- * @param Config $config
- */
- public function __construct(ResolverInterface $resolver, Config $config)
- {
- $this->resolver = $resolver;
- $this->config = $config;
- }
- /**
- * @inheritdoc
- */
- public function getDefaultLocalePath()
- {
- return $this->resolver->getDefaultLocalePath();
- }
- /**
- * @inheritdoc
- */
- public function setDefaultLocale($locale)
- {
- return $this->resolver->setDefaultLocale($locale);
- }
- /**
- * @inheritdoc
- */
- public function getDefaultLocale()
- {
- return $this->resolver->getDefaultLocale();
- }
- /**
- * @inheritdoc
- */
- public function setLocale($locale = null)
- {
- return $this->resolver->setLocale($locale);
- }
- /**
- * Gets store's locale or the `en_US` locale if store's locale does not supported by PayPal.
- *
- * @return string
- */
- public function getLocale()
- {
- $locale = $this->resolver->getLocale();
- $allowedLocales = $this->config->getValue('supported_locales');
- return strpos($allowedLocales, $locale) !== false ? $locale : 'en_US';
- }
- /**
- * @inheritdoc
- */
- public function emulate($scopeId)
- {
- return $this->resolver->emulate($scopeId);
- }
- /**
- * @inheritdoc
- */
- public function revert()
- {
- return $this->resolver->revert();
- }
- }
|