本文整理汇总了PHP中Magento\Directory\Helper\Data::isShowNonRequiredState方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::isShowNonRequiredState方法的具体用法?PHP Data::isShowNonRequiredState怎么用?PHP Data::isShowNonRequiredState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Directory\Helper\Data
的用法示例。
在下文中一共展示了Data::isShowNonRequiredState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toOptionArray
/**
* Convert collection items to select options array
*
* @param string|boolean $emptyLabel
* @return array
*/
public function toOptionArray($emptyLabel = ' ')
{
$options = $this->_toOptionArray('country_id', 'name', ['title' => 'iso2_code']);
$sort = [];
foreach ($options as $data) {
$name = (string) $this->_localeLists->getCountryTranslation($data['value']);
if (!empty($name)) {
$sort[$name] = $data['value'];
}
}
$this->_arrayUtils->ksortMultibyte($sort, $this->_localeResolver->getLocale());
foreach (array_reverse($this->_foregroundCountries) as $foregroundCountry) {
$name = array_search($foregroundCountry, $sort);
unset($sort[$name]);
$sort = [$name => $foregroundCountry] + $sort;
}
$isRegionVisible = (bool) $this->helperData->isShowNonRequiredState();
$options = [];
foreach ($sort as $label => $value) {
$option = ['value' => $value, 'label' => $label];
if ($this->helperData->isRegionRequired($value)) {
$option['is_region_required'] = true;
} else {
$option['is_region_visible'] = $isRegionVisible;
}
if ($this->helperData->isZipCodeOptional($value)) {
$option['is_zipcode_optional'] = true;
}
$options[] = $option;
}
if (count($options) > 0 && $emptyLabel !== false) {
array_unshift($options, ['value' => '', 'label' => $emptyLabel]);
}
return $options;
}
示例2: getShowAllRegions
/**
* Return, whether non-required state should be shown
*
* @return int 1 if should be shown, and 0 if not.
*/
public function getShowAllRegions()
{
return (string) $this->_directoryHelper->isShowNonRequiredState() ? 1 : 0;
}