Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Locale Class Reference

Public Member Functions

 __construct (Lists $lists)
 
 isValid ($localeCode)
 

Protected Attributes

 $lists
 

Detailed Description

Locale validator model

Definition at line 14 of file Locale.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Lists  $lists)

Constructor

Parameters
Lists$lists

Definition at line 26 of file Locale.php.

27  {
28  $this->lists = $lists;
29  }

Member Function Documentation

◆ isValid()

isValid (   $localeCode)

Validate locale code. Code must be in the list of allowed locales.

Parameters
string$localeCode
Returns
bool

@api

Definition at line 39 of file Locale.php.

40  {
41  $isValid = true;
42  $allowedLocaleCodes = array_keys($this->lists->getLocaleList());
43 
44  if (!$localeCode || !in_array($localeCode, $allowedLocaleCodes)) {
45  $isValid = false;
46  }
47 
48  return $isValid;
49  }

Field Documentation

◆ $lists

$lists
protected

Definition at line 19 of file Locale.php.


The documentation for this class was generated from the following file: