Exemplo n.º 1
0
 /**
  * Set locale
  *
  * @param string $locale
  * @return $this
  */
 public function setLocale($locale = null)
 {
     $forceLocale = $this->_request->getParam('locale', null);
     if (!$this->_localeValidator->isValid($forceLocale)) {
         $forceLocale = false;
     }
     $sessionLocale = $this->_session->getSessionLocale();
     $userLocale = $this->_localeManager->getUserInterfaceLocale();
     $localeCodes = array_filter([$forceLocale, $sessionLocale, $userLocale]);
     if (count($localeCodes)) {
         $locale = reset($localeCodes);
     }
     return parent::setLocale($locale);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider testIsValidDataProvider
  * @param string $locale
  * @param boolean $valid
  * @covers \Magento\Framework\Locale\Validator::isValid
  */
 public function testIsValid($locale, $valid)
 {
     $this->assertEquals($valid, $this->_validatorModel->isValid($locale));
 }