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


PHP static::errors方法代码示例

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


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

示例1: valid

 public static function valid($rules, $data)
 {
     static::$errors = [];
     Event::triggerOnce('core.check.init');
     self::$data = $data;
     foreach ($rules as $field_name => $rule) {
         $current = isset($data[$field_name]) ? $data[$field_name] : null;
         if (is_callable($rule)) {
             static::$errors[$field_name] = call_user_func($rule, $current);
             continue;
         } elseif (is_string($rule)) {
             $current_rules = array_flip(preg_split('/\\s*\\|\\s*/', $rule));
         } else {
             $current_rules = (array) $rule;
         }
         static::$errors[$field_name] = true;
         foreach ($current_rules as $method => $message) {
             $meth_name = strtok($method, ':');
             $meth_opts = array_merge([$current], json_decode('[' . strtok(':') . ']'));
             if (static::$errors[$field_name] !== true) {
                 continue 2;
             }
             static::$errors[$field_name] = true;
             if (isset(static::$methods[$meth_name])) {
                 static::$errors[$field_name] = call_user_func_array(static::$methods[$meth_name], $meth_opts);
             }
         }
     }
     self::$data = [];
     // Clean non-errors
     static::$errors = array_filter(static::$errors, function ($v) {
         return $v !== true;
     });
     return empty(static::$errors);
 }
开发者ID:evil-enterprises,项目名称:phpcore,代码行数:35,代码来源:Check.php

示例2: isValid

 public static function isValid($data, $rules)
 {
     $validation = Validator::make($data, $rules);
     if ($validation->passes()) {
         return true;
     }
     static::$errors = $validation->messages();
     return false;
 }
开发者ID:vjyac,项目名称:guiavirasoro,代码行数:9,代码来源:Busqueda.php

示例3: is_valid

 public function is_valid($data)
 {
     $validator = Validator::make($data, static::$rules);
     if ($validator->passes()) {
         return true;
     }
     static::$errors = $validator->messages();
     return FALSE;
 }
开发者ID:imsgithub,项目名称:hotlot.com,代码行数:9,代码来源:User.php

示例4: __construct

 public function __construct()
 {
     if (!isset(static::$errors)) {
         if (Session::started() and Session::has('errors')) {
             static::$errors = Session::get('errors');
         } else {
             static::$errors = new Messages();
         }
     }
 }
开发者ID:juaniiie,项目名称:mwi,代码行数:10,代码来源:installer.php

示例5: validate

 public static function validate($data, $rules = NULL, $messages = array())
 {
     if (is_null($rules)) {
         $rules = static::$rules;
     }
     $validation = Validator::make($data, $rules, $messages);
     if ($validation->fails()) {
         static::$errors = $validation->messages()->all();
         return FALSE;
     }
     return TRUE;
 }
开发者ID:Grapheme,项目名称:amway,代码行数:12,代码来源:BaseModel.php

示例6: validate

 public static function validate($formData)
 {
     $factory = new Factory(new Translator('en'));
     $v = $factory->make($formData, static::$rules, static::$messages);
     if ($v->fails()) {
         $errors = array();
         foreach ($v->messages()->all('<li>:message</li>') as $error) {
             $errors[] = $error;
         }
         static::$errors = implode("", $errors);
         return false;
     }
     return true;
 }
开发者ID:sarfraznawaz2005,项目名称:slim2-basic-app,代码行数:14,代码来源:Model.php

示例7: valid

 public static function valid($rules, $data)
 {
     static::$errors = [];
     static::triggerOnce('init');
     self::$data = $data = (array) $data;
     foreach ((array) $rules as $field_name => $rule) {
         $current = isset($data[$field_name]) ? $data[$field_name] : null;
         if (is_callable($rule)) {
             static::$errors[$field_name] = call_user_func($rule, $current);
             continue;
         } elseif (is_string($rule)) {
             $current_rules = array_flip(preg_split('/\\s*\\|\\s*/', $rule));
         } else {
             $current_rules = (array) $rule;
         }
         static::$errors[$field_name] = true;
         foreach ($current_rules as $method => $message) {
             $meth_name = strtok($method, ':');
             $opts = strtok(':') ?: '';
             $opts = $opts ? json_decode("[{$opts}]") : [];
             $meth_opts = $opts ? array_merge([$current], $opts) : [$current];
             if (static::$errors[$field_name] !== true) {
                 continue 2;
             }
             if (empty(static::$methods[$meth_name])) {
                 static::$errors[$field_name] = true;
             } else {
                 if (call_user_func_array(static::$methods[$meth_name]->validate, $meth_opts)) {
                     static::$errors[$field_name] = true;
                 } else {
                     $arg = [];
                     foreach ($meth_opts as $key => $value) {
                         $arg["arg_{$key}"] = $value;
                     }
                     static::$errors[$field_name] = Text::render(static::$methods[$meth_name]->message, $arg);
                 }
             }
         }
     }
     self::$data = [];
     // Clean non-errors
     static::$errors = array_filter(static::$errors, function ($v) {
         return $v !== true;
     });
     return empty(static::$errors);
 }
开发者ID:caffeina-core,项目名称:core,代码行数:46,代码来源:Check.php

示例8: process

 public static function process($value, $settings, $model)
 {
     $settings = static::settings($settings);
     $disallowed = \Arr::get($settings, 'disallowed_prefixes');
     static::$errors = array();
     $rules = "";
     /*$extraRules = $value['extrarules'];
       unset($value['extrarules']);*/
     if (empty($value)) {
         return '';
     }
     foreach ($value as $val) {
         if (!is_array($val)) {
             continue;
         }
         $action = @$val['action'] ?: 301;
         $rules .= implode(static::ARG_SEPARATOR, array('RewriteRule', $val['from'], $val['to'], "[R={$action},L]\r\n"));
         if (!($fromValid = static::isValidRewriteArgument($val['from']))) {
             static::$errors[] = "An error was found in the syntax of '{$val['from']}'";
         }
         if (!($toValid = static::isValidRewriteArgument($val['to']))) {
             static::$errors[] = "An error was found in the syntax of '{$val['to']}'";
         }
         if ($fromValid && is_array($disallowed)) {
             foreach ($disallowed as $disallow) {
                 if (static::matchesPrefix($disallow, $val['from'])) {
                     static::$errors[] = "Cannot add a rule that matches '{$disallow}'";
                     break;
                 }
             }
         }
     }
     // Only insert if all the syntax is valid
     if (!count(static::$errors)) {
         self::insertToHtaccess($rules);
     }
     return $rules;
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:38,代码来源:Htaccess.php

示例9: cleanErrors

 /**
  * Clean errors
  */
 protected static function cleanErrors()
 {
     static::$errors = array();
 }
开发者ID:k-kalashnikov,项目名称:geekcon,代码行数:7,代码来源:base.php

示例10: response

 /**
  * Respone json errors payload.
  *
  * @param int $status
  *
  * @return \Response
  */
 public function response($status = 400, array $headers = [], $options = 0)
 {
     $errors = static::$errors;
     static::$errors = [];
     return response()->json(['errors' => $errors], $status, $headers, $options);
 }
开发者ID:jenky,项目名称:laravel-api-starter,代码行数:13,代码来源:Api.php

示例11: _reset

 /**
  * Reset internal variables for another validation run.
  *
  * @return void
  */
 protected static function _reset()
 {
     static::$errors = array();
 }
开发者ID:yuuicchan0912,项目名称:sample1,代码行数:9,代码来源:Validation.php

示例12: disable

 public static function disable($module_slug)
 {
     $module = Module::make($module_slug);
     if (!$module->is_valid()) {
         static::$errors = $module->errors;
         return false;
     }
     $dependencies = $module->has_dependencies();
     if (empty($dependencies)) {
         $db_module = Model\Module::where('slug', '=', $module_slug)->first();
         if (isset($db_module) and !empty($db_module)) {
             $db_module->enabled = 0;
             $db_module->save();
             \Bundle::disable($module_slug);
             return true;
         } else {
             static::$errors->add('installer', 'Module [' . $module_slug . '] must be installed.');
             return false;
         }
     } else {
         foreach ($dependencies as $dependency_slug => $module) {
             static::$errors->add('installer', 'Module [' . $module_slug . '] cannot be disabled. Please disable ' . $dependency_slug . ' module first.');
         }
         return false;
     }
 }
开发者ID:juaniiie,项目名称:mwi,代码行数:26,代码来源:installer.php

示例13: addMessageResponse

 /**
  * Collect messages retrieved from file processors.
  *
  * @param $messages
  * @param bool $error
  */
 protected function addMessageResponse($messages, $error = false)
 {
     if (is_string($messages)) {
         $messages = [$messages];
     } elseif ($messages instanceof MessageProviderInterface) {
         $messages = $messages->getMessageBag()->getMessages();
     } else {
         return null;
         // We don't have anything to add in this case.
     }
     if ($error) {
         static::$errors = array_merge(static::$errors, $messages);
     } else {
         static::$messages = array_merge(static::$messages, $messages);
     }
 }
开发者ID:bmartel,项目名称:phperclip,代码行数:22,代码来源:FileProcessorAdapter.php

示例14: endProducts

 /**
  * @param $product_ids
  * @throws \Exception
  * @throws \SmartyException
  */
 protected static function endProducts(array $product_ids)
 {
     static::$count_success = 0;
     static::$count_fail = 0;
     static::$count_skip = 0;
     static::$errors = array();
     static::$error_counter = array();
     $product_ids = array_filter($product_ids);
     $templates = $groups = array();
     fn_set_progress('parts', count($product_ids));
     foreach ($product_ids as $product_id) {
         $product = new Product($product_id, array('external'));
         if (empty($product->external_id) || $product->statusIsClosed()) {
             if (empty($product->external_id)) {
                 static::setError('100_' . $product_id, __('ebay_product_not_exported', array('[product]' => $product->original_title)), true);
             } else {
                 static::setError('101_' . $product_id, __('ebay_product_already_sales_closed', array('[product]' => $product->original_title)), true);
             }
             fn_set_progress('echo', '.');
             static::$count_skip++;
             continue;
         }
         if (!isset($templates[$product->template_id])) {
             $templates[$product->template_id] = $product->getTemplate();
         }
         $groups[$product->template_id][] = $product;
         if (count($groups[$product->template_id]) >= static::MAX_COUNT_END_PRODUCTS) {
             static::endGroupProducts($templates[$product->template_id], $groups[$product->template_id]);
             unset($groups[$product->template_id]);
         }
     }
     if (!empty($groups)) {
         foreach ($groups as $template_id => $products) {
             static::endGroupProducts($templates[$template_id], $products);
         }
     }
     /** @var \Smarty $smarty */
     $smarty = Tygh::$app['view'];
     $smarty->assign('end_result', array('count_success' => static::$count_success, 'count_fail' => static::$count_fail, 'count_skip' => static::$count_skip, 'errors' => static::$errors, 'error_counter' => static::$error_counter, 'count_external_error' => static::$count_external_error));
     fn_set_notification('I', __('ebay_end_summary_title'), $smarty->fetch('addons/ebay/views/ebay/components/end_summary.tpl'));
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:46,代码来源:Controller.php

示例15: _reset

 /**
  * Reset internal variables for another validation run.
  *
  * @return void
  */
 protected static function _reset()
 {
     static::$errors = [];
 }
开发者ID:hossain-seaos,项目名称:cakephp,代码行数:9,代码来源:Validation.php


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