當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfToolkit::isArrayValuesEmpty方法代碼示例

本文整理匯總了PHP中sfToolkit::isArrayValuesEmpty方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfToolkit::isArrayValuesEmpty方法的具體用法?PHP sfToolkit::isArrayValuesEmpty怎麽用?PHP sfToolkit::isArrayValuesEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfToolkit的用法示例。


在下文中一共展示了sfToolkit::isArrayValuesEmpty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validate

 /**
  * Validates a file or parameter.
  *
  * @param string A file or parameter name
  * @param array  Data associated with the file or parameter
  * @param string A parent name
  *
  * @return bool true, if validation completes successfully, otherwise false
  */
 protected function validate(&$name, &$data, $parent)
 {
     // get defaults
     $error = null;
     $errorName = null;
     $force = null !== $data['group'] ? $data['group']['_force'] : false;
     $retval = true;
     $value = null;
     // get our parameter value
     if ($parent == null) {
         // normal file/parameter
         $errorName = $name;
         if ($data['is_file']) {
             // file
             $value = $this->request->getFile($name);
         } else {
             // parameter
             $value = $this->request->getParameterHolder()->get($name);
         }
     } else {
         // we have a parent
         $errorName = $parent . '{' . $name . '}';
         if ($data['is_file']) {
             // file
             $parent = $this->request->getFile($parent . '[' . $name . ']');
             if ($parent != null) {
                 $value = $parent;
             }
         } else {
             // parameter
             $parent = $this->request->getParameterHolder()->get($parent);
             if ($parent != null && isset($parent[$name])) {
                 $value = $parent[$name];
             }
         }
     }
     // now for the dirty work
     if ($data['is_file'] && !$value['name'] || !$data['is_file'] && (is_array($value) ? sfToolkit::isArrayValuesEmpty($value) : $value === null || strlen($value) == 0)) {
         if ($data['required'] || $force) {
             // it's empty!
             $error = $data['required_msg'];
             $retval = false;
         } else {
             // we don't have to validate it
             $retval = true;
         }
     } else {
         // time for the fun
         $error = null;
         // get group force status
         if ($data['group'] != null) {
             // we set this because we do have a value for a parameter in this group
             $data['group']['_force'] = true;
         }
         if (count($data['validators']) > 0) {
             // loop through our validators
             foreach ($data['validators'] as $validator) {
                 if (!$validator->execute($value, $error)) {
                     $retval = false;
                     break;
                 }
             }
         }
     }
     if (!$retval) {
         // set validation status
         $data['validation_status'] = false;
         // set the request error
         $this->request->setError($errorName, $error);
     }
     return $retval;
 }
開發者ID:souravmondal-cn,項目名稱:symfonyweather,代碼行數:81,代碼來源:sfValidatorManager.class.php

示例2: validate

 protected function validate(&$name, &$data, $parent)
 {
     $error = null;
     $errorName = null;
     $force = null !== $data['group'] ? $data['group']['_force'] : false;
     $retval = true;
     $value = null;
     if ($parent == null) {
         $errorName = $name;
         if ($data['is_file']) {
             $value = $this->request->getFile($name);
         } else {
             $value = $this->request->getParameterHolder()->get($name);
         }
     } else {
         $errorName = $parent . '{' . $name . '}';
         if ($data['is_file']) {
             $parent = $this->request->getFile($parent . '[' . $name . ']');
             if ($parent != null) {
                 $value = $parent;
             }
         } else {
             $parent = $this->request->getParameterHolder()->get($parent);
             if ($parent != null && isset($parent[$name])) {
                 $value = $parent[$name];
             }
         }
     }
     if ($data['is_file'] && !$value['name'] || !$data['is_file'] && (is_array($value) ? sfToolkit::isArrayValuesEmpty($value) : $value === null || strlen($value) == 0)) {
         if ($data['required'] || $force) {
             $error = $data['required_msg'];
             $retval = false;
         } else {
             $retval = true;
         }
     } else {
         $error = null;
         if ($data['group'] != null) {
             $data['group']['_force'] = true;
         }
         if (count($data['validators']) > 0) {
             foreach ($data['validators'] as $validator) {
                 if (!$validator->execute($value, $error)) {
                     $retval = false;
                     break;
                 }
             }
         }
     }
     if (!$retval) {
         $data['validation_status'] = false;
         $this->request->setError($errorName, $error);
     }
     return $retval;
 }
開發者ID:kotow,項目名稱:work,代碼行數:55,代碼來源:config_core_compile.yml.php


注:本文中的sfToolkit::isArrayValuesEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。