本文整理匯總了PHP中format::options方法的典型用法代碼示例。如果您正苦於以下問題:PHP format::options方法的具體用法?PHP format::options怎麽用?PHP format::options使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類format
的用法示例。
在下文中一共展示了format::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();
}
}