当前位置: 首页>>代码示例>>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;未经允许,请勿转载。