當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。