当前位置: 首页>>代码示例>>PHP>>正文


PHP factory::method方法代码示例

本文整理汇总了PHP中factory::method方法的典型用法代码示例。如果您正苦于以下问题:PHP factory::method方法的具体用法?PHP factory::method怎么用?PHP factory::method使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在factory的用法示例。


在下文中一共展示了factory::method方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: method

 /**
  * Call validator method
  *
  * @param string $method
  * @param array $params
  * @param array $options
  * @param array $neighbouring_values
  * @return array
  */
 public static function method($method, $value, $params = [], $options = [], $neighbouring_values = [])
 {
     $method = factory::method($method);
     $params = $params ?? [];
     $params['options'] = $options;
     $params['neighbouring_values'] = $neighbouring_values;
     return factory::model($method[0], true)->{$method[1]}($value, $params);
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:17,代码来源:base.php

示例2: acl_handle

 /**
  * Acl handle
  *
  * @param string $acl_key
  * @param string $acl_type
  * @param array $data
  * @param array $options
  * @return boolean
  */
 public function acl_handle($acl_key, $acl_type, &$data, &$options)
 {
     // if we have no acls we must return null
     if (empty($this->data[$acl_key][$acl_type])) {
         return null;
     }
     // sort
     array_key_sort($this->data[$acl_key][$acl_type], ['order' => SORT_ASC], ['order' => SORT_NUMERIC]);
     // process one by one
     foreach ($this->data[$acl_key][$acl_type] as $k => $v) {
         $method = factory::method($v['method'], null, true);
         $result = $method[0]->{$method[1]}($acl_key, $acl_type, $data, $options);
         if (!$result) {
             debug::$data['acls'][$acl_key][$acl_type] = 'Failed';
             return false;
         } else {
             debug::$data['acls'][$acl_key][$acl_type] = 'Success';
         }
     }
     return true;
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:30,代码来源:class.php

示例3: 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();
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:42,代码来源:format.php

示例4: options

 /**
  * Options
  *
  * @param array $data
  * @param array $options_map
  * @param array $options
  * @return array
  */
 public static function options($data, $options_map, $options = [])
 {
     $i18n = [];
     $format = [];
     $options_map_new = [];
     $format_methods = [];
     foreach ($options_map as $k => $v) {
         if (is_array($v)) {
             $options_map_new[$k] = $v['field'];
             if (!empty($options['i18n']) && !empty($v['i18n']) && !array_key_exists('i18n', $v)) {
                 $i18n[$k] = !empty($options['i18n']);
             }
             if (!empty($v['format'])) {
                 $format[$k] = $v;
                 $format_methods[$k] = factory::method($v['format'], 'format');
             }
         } else {
             $options_map_new[$k] = $v;
             if (!empty($options['i18n'])) {
                 $i18n[$k] = true;
             }
         }
     }
     // we need to i18n and process formats
     if (!empty($i18n) || !empty($format)) {
         foreach ($data as $k => $v) {
             // localize
             if (!empty($i18n)) {
                 foreach ($i18n as $k2 => $v2) {
                     // we need to skip few things
                     if (!isset($data[$k][$k2])) {
                         continue;
                     }
                     $data[$k][$k2] = i18n(null, $data[$k][$k2]);
                 }
             }
             // format
             if (!empty($format)) {
                 foreach ($format as $k2 => $v2) {
                     $data[$k][$k2] = call_user_func_array([$format_methods[$k2][0], $format_methods[$k2][1]], [$data[$k][$k2], $v2['format_options'] ?? []]);
                 }
             }
         }
     }
     // inactive
     $inactive_message = '*Inactive';
     $i18n_inactive = !empty($options['i18n']) ? i18n(null, $inactive_message) : $inactive_message;
     foreach ($data as $k => $v) {
         if (!empty($options['column_prefix']) && !empty($v[$options['column_prefix'] . 'inactive'])) {
             $options_map_new[$options['column_prefix'] . 'inactive'] = 'inactive';
             $options_map_new['__prepend'] = 'name';
             $data[$k]['__prepend'] = $i18n_inactive;
         }
     }
     return remap($data, $options_map_new);
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:64,代码来源:common.php

示例5: render_element_value

 /**
  * Render elements value
  *
  * @param array $options
  * @param mixed $value
  * @param array $neighbouring_values
  * @return string
  * @throws Exception
  */
 public function render_element_value(&$options, $value = null, &$neighbouring_values = [])
 {
     // field name and values_key
     $options['options']['field_name'] = $options['options']['details_field_name'] ?? $options['options']['name'];
     $options['options']['field_values_key'] = implode('[::]', $options['options']['field_values_key'] ?? [$options['options']['field_name']]);
     // custom renderer
     if (!empty($options['options']['custom_renderer'])) {
         $method = factory::method($options['options']['custom_renderer'], null, true);
         $options_custom_renderer = $options;
         call_user_func_array($method, [&$this, &$options, &$value, &$neighbouring_values]);
     }
     // handling override_field_value method
     if (!empty($this->wrapper_methods['override_field_value']['main'])) {
         call_user_func_array($this->wrapper_methods['override_field_value']['main'], [&$this, &$options, &$value, &$neighbouring_values]);
     }
     $result_options = $options['options'];
     $options['options']['value'] = $value;
     array_key_extract_by_prefix($result_options, 'label_');
     $element_expand = !empty($result_options['expand']);
     $html_suffix = $result_options['html_suffix'] ?? '';
     // unset certain keys
     unset($result_options['order'], $result_options['required'], $result_options['html_suffix']);
     // processing options
     $flag_select_or_autocomplete = !empty($result_options['options_model']) || !empty($result_options['options']);
     if (!empty($result_options['options_model'])) {
         if (empty($result_options['options_params'])) {
             $result_options['options_params'] = [];
         }
         if (empty($result_options['options_options'])) {
             $result_options['options_options'] = [];
         }
         $result_options['options_options']['i18n'] = $result_options['options_options']['i18n'] ?? true;
         $result_options['options_options']['acl'] = $result_options['options_options']['acl'] ?? $this->acl;
         if (empty($result_options['options_depends'])) {
             $result_options['options_depends'] = [];
         }
         // options depends & params
         $this->process_params_and_depends($result_options['options_depends'], $neighbouring_values, $options, true);
         $this->process_params_and_depends($result_options['options_params'], $neighbouring_values, $options, false);
         $result_options['options_params'] = array_merge_hard($result_options['options_params'], $result_options['options_depends']);
         // we do not need options for autocomplete
         if (strpos($result_options['method'], 'autocomplete') === false) {
             $skip_values = [];
             if (!empty($options['options']['details_key'])) {
                 if (!empty($options['options']['details_parent_key'])) {
                     $temp_key = $options['options']['details_parent_key'] . '::' . $options['options']['details_key'];
                     if (!empty($this->misc_settings['details_unique_select'][$temp_key][$options['options']['details_field_name']][$options['options']['__parent_row_number']])) {
                         $skip_values = array_keys($this->misc_settings['details_unique_select'][$temp_key][$options['options']['details_field_name']][$options['options']['__parent_row_number']]);
                     }
                 } else {
                     if (!empty($this->misc_settings['details_unique_select'][$options['options']['details_key']][$options['options']['details_field_name']])) {
                         $skip_values = array_keys($this->misc_settings['details_unique_select'][$options['options']['details_key']][$options['options']['details_field_name']]);
                     }
                 }
             }
             $result_options['options'] = object_data_common::process_options($result_options['options_model'], $this, $result_options['options_params'], $value, $skip_values, $result_options['options_options']);
         } else {
             // we need to inject form id into autocomplete
             $result_options['form_id'] = "form_{$this->form_link}_form";
         }
     }
     // by default all selects are searchable if not specified otherwise
     if ($flag_select_or_autocomplete) {
         $result_options['searchable'] = $result_options['searchable'] ?? false;
     }
     // different handling for different type
     switch ($options['type']) {
         case 'container':
             $options_container = $options;
             //$options_container['previous_data'] = $v;
             // todo: pass $form_data_key from parent
             $options_container['previous_key'] = $options['previous_key'];
             // render container
             $temp_container_value = $this->render_container($data['fm_part_child_container_name'], $parents, $options_container);
             if (!empty($html_expand)) {
                 // get part id
                 $temp_id = $this->id('part_details', ['part_name' => $data['fm_part_name'], 'part_id' => $options_container['previous_id']]);
                 $temp_id_div_inner = $temp_id . '_html_expand_div_inner';
                 $temp_expand_div_inner = ['id' => $temp_id_div_inner, 'style' => 'display: none;', 'value' => $temp_container_value];
                 $temp_expand_div_a = ['href' => 'javascript:void(0);', 'onclick' => "numbers.element.toggle('{$temp_id_div_inner}');", 'value' => '+ / -'];
                 $temp_expand_div_outer = ['align' => 'left', 'value' => html::a($temp_expand_div_a) . '<br />' . html::div($temp_expand_div_inner)];
                 $value = html::div($temp_expand_div_outer);
             } else {
                 $value = $temp_container_value;
             }
             $result_options['value'] = $value;
             break;
         case 'field':
             $element_method = $result_options['method'] ?? 'html::input';
             if (strpos($element_method, '::') === false) {
                 $element_method = 'html::' . $element_method;
//.........这里部分代码省略.........
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:101,代码来源:base.php

示例6: render_data_default

 /**
  * Data default renderer
  *
  * @return string
  */
 private final function render_data_default()
 {
     $result = '';
     // if we have no rows we display a messsage
     if ($this->num_rows == 0) {
         return html::message(['type' => 'warning', 'options' => [i18n(null, object_content_messages::no_rows_found)]]);
     }
     $counter = 1;
     $table = ['header' => [], 'options' => []];
     // action flags
     $actions = [];
     if (object_controller::can('record_view')) {
         $actions['view'] = true;
     }
     // generate columns
     foreach ($this->columns as $k => $v) {
         // if we can not view we skip action column
         if (empty($actions) && $k == 'action') {
             continue;
         }
         $table['header'][$k] = ['value' => i18n(null, $v['name']), 'nowrap' => true, 'width' => $v['width'] ?? null];
     }
     // generate rows
     foreach ($this->rows as $k => $v) {
         // process all columns first
         $row = [];
         foreach ($this->columns as $k2 => $v2) {
             // if we can not view we skip action column
             if (empty($actions) && $k2 == 'action') {
                 continue;
             }
             $value = [];
             // create cell properties
             foreach (['width', 'align'] as $v3) {
                 if (isset($v2[$v3])) {
                     $value[$v3] = $v2[$v3];
                 }
             }
             // process rows
             if ($k2 == 'action') {
                 $value['value'] = [];
                 if (!empty($actions['view'])) {
                     $mvc = application::get('mvc');
                     $pk = extract_keys($this->model_object->pk, $v);
                     $url = $mvc['controller'] . '/_edit?' . http_build_query2($pk);
                     $value['value'][] = html::a(['value' => i18n(null, 'View'), 'href' => $url]);
                 }
                 $value['value'] = implode(' ', $value['value']);
             } else {
                 if ($k2 == 'row_number') {
                     $value['value'] = format::id($counter) . '.';
                 } else {
                     if ($k2 == 'offset_number') {
                         $value['value'] = format::id($this->offset + $counter) . '.';
                     } else {
                         if (!empty($v2['options_model'])) {
                             if (strpos($v2['options_model'], '::') === false) {
                                 $v2['options_model'] .= '::options';
                             }
                             $params = $v2['options_params'] ?? [];
                             if (!empty($v2['options_depends'])) {
                                 foreach ($v2['options_depends'] as $k0 => $v0) {
                                     $params[$k0] = $v[$v0];
                                 }
                             }
                             $crypt_object = new crypt();
                             $hash = $crypt_object->hash($v2['options_model'] . serialize($params));
                             if (!isset($this->cached_options[$hash])) {
                                 $method = factory::method($v2['options_model'], null, true);
                                 $this->cached_options[$hash] = call_user_func_array($method, [['where' => $params]]);
                             }
                             if (isset($this->cached_options[$hash][$v[$k2]])) {
                                 $value['value'] = $this->cached_options[$hash][$v[$k2]]['name'];
                             } else {
                                 $value['value'] = null;
                             }
                         } else {
                             if (!empty($v2['options']) && !is_array($v[$k2])) {
                                 if (isset($v2['options'][$v[$k2]])) {
                                     $value['value'] = $v2['options'][$v[$k2]]['name'];
                                 } else {
                                     $value['value'] = null;
                                 }
                             } else {
                                 if (isset($v[$k2])) {
                                     $value['value'] = $v[$k2];
                                 } else {
                                     $value['value'] = null;
                                 }
                             }
                         }
                     }
                 }
             }
             // put value into row
//.........这里部分代码省略.........
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:101,代码来源:base.php


注:本文中的factory::method方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。