Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
LocaleResolver.php
Go to the documentation of this file.
1 <?php
7 
10 
12 {
16  private $resolver;
17 
21  private $config;
22 
27  public function __construct(ResolverInterface $resolver, Config $config)
28  {
29  $this->resolver = $resolver;
30  $this->config = $config;
31  }
32 
36  public function getDefaultLocalePath()
37  {
38  return $this->resolver->getDefaultLocalePath();
39  }
40 
44  public function setDefaultLocale($locale)
45  {
46  return $this->resolver->setDefaultLocale($locale);
47  }
48 
52  public function getDefaultLocale()
53  {
54  return $this->resolver->getDefaultLocale();
55  }
56 
60  public function setLocale($locale = null)
61  {
62  return $this->resolver->setLocale($locale);
63  }
64 
70  public function getLocale()
71  {
72  $locale = $this->resolver->getLocale();
73  $allowedLocales = $this->config->getValue('supported_locales');
74 
75  return strpos($allowedLocales, $locale) !== false ? $locale : 'en_US';
76  }
77 
81  public function emulate($scopeId)
82  {
83  return $this->resolver->emulate($scopeId);
84  }
85 
89  public function revert()
90  {
91  return $this->resolver->revert();
92  }
93 }
$config
Definition: fraud_order.php:17
__construct(ResolverInterface $resolver, Config $config)