本文整理汇总了PHP中format::defaut_options方法的典型用法代码示例。如果您正苦于以下问题:PHP format::defaut_options方法的具体用法?PHP format::defaut_options怎么用?PHP format::defaut_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format
的用法示例。
在下文中一共展示了format::defaut_options方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialize
*
* @param array $options
*/
public static function init($options = [])
{
// default options
self::$defaut_options = ['language_code' => 'sys', 'locale' => 'en_CA.UTF-8', 'timezone' => 'America/Toronto', 'server_timezone' => application::get('php.date.timezone'), 'date' => 'Y-m-d', 'time' => 'H:i:s', 'datetime' => 'Y-m-d H:i:s', 'timestamp' => 'Y-m-d H:i:s.u', 'amount_frm' => 20, 'amount_fs' => 40, 'settings' => ['currency_codes' => []], 'locale_locales' => [], 'locale_locale_js' => null, 'locale_set_name' => null, 'locale_options' => [], 'locale_override_class' => null];
// settings from config files
$config = application::get('flag.global.format');
// settings from user account
$entity = entity::groupped('format');
// merge all of them together
self::$options = array_merge_hard(self::$defaut_options, $config, i18n::$options, $entity, $options);
// fix utf8
self::$options['locale'] = str_replace(['utf8', 'utf-8'], 'UTF-8', self::$options['locale']);
// generate a list of available locales
$locale_settings = self::set_locale(self::$options['locale'], self::$defaut_options['locale']);
self::$options = array_merge_hard(self::$options, $locale_settings);
// fix values
self::$options['amount_frm'] = (int) self::$options['amount_frm'];
self::$options['amount_fs'] = (int) self::$options['amount_fs'];
self::$options['locale_options']['mon_thousands_sep'] = self::$options['locale_options']['mon_thousands_sep'] ?? ',';
self::$options['locale_options']['mon_decimal_point'] = self::$options['locale_options']['mon_decimal_point'] ?? '.';
if (empty(self::$options['locale_options']['mon_grouping'])) {
self::$options['locale_options']['mon_grouping'] = [3, 3];
}
// load data from models
if (!empty(self::$options['model'])) {
foreach (self::$options['model'] as $k => $v) {
$method = factory::method($v, null);
self::$options['settings'][$k] = factory::model($method[0], true)->{$method[1]}();
}
unset(self::$options['model']);
}
// push js format version to frontend
if (!empty(self::$options['locale_override_class'])) {
$locale_override_class = self::$options['locale_override_class'];
$locale_override_class::js();
}
}