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


PHP sfValidatorBase::clean方法代码示例

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


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

示例1: clean

 private function clean(sfValidatorBase $v, $value)
 {
     $this->result = 'true';
     try {
         $v->clean($value);
     } catch (Exception $e) {
         $this->result = 'false';
     }
     $this->renderText($this->result);
 }
开发者ID:limitium,项目名称:uberlov,代码行数:10,代码来源:actions.class.php

示例2: doAskAndValidate

 /**
  * @see askAndValidate()
  */
 public static function doAskAndValidate(sfTask $task, $question, sfValidatorBase $validator, array $options = array())
 {
     if (!is_array($question)) {
         $question = array($question);
     }
     $options = array_merge(array('value' => null, 'attempts' => 3, 'style' => 'QUESTION'), $options);
     while ($options['attempts']--) {
         $value = is_null($options['value']) ? $task->ask(isset($error) && 'required' != $error->getCode() ? array_merge(array($error->getMessage(), ''), $question) : $question, isset($error) ? 'ERROR' : $options['style']) : $options['value'];
         try {
             $value = $validator->clean($value);
             return $value;
         } catch (sfValidatorError $error) {
             $value = null;
         }
     }
     throw $error;
 }
开发者ID:jmiridis,项目名称:atcsf1,代码行数:20,代码来源:sfTaskExtraBaseTask.class.php

示例3: askAndValidate

 /**
  * Asks for a value and validates the response.
  *
  * Available options:
  *
  *  * value:    A value to try against the validator before asking the user
  *  * attempts: Max number of times to ask before giving up (false by default, which means infinite)
  *  * style:    Style for question output (QUESTION by default)
  *
  * @param   string|array    $question
  * @param   sfValidatorBase $validator
  * @param   array           $options
  *
  * @return  mixed
  */
 public function askAndValidate($question, sfValidatorBase $validator, array $options = array())
 {
     if (!is_array($question)) {
         $question = array($question);
     }
     $options = array_merge(array('value' => null, 'attempts' => false, 'style' => 'QUESTION'), $options);
     // does the provided value passes the validator?
     if ($options['value']) {
         try {
             return $validator->clean($options['value']);
         } catch (sfValidatorError $error) {
         }
     }
     // no, ask the user for a valid user
     $error = null;
     while (false === $options['attempts'] || $options['attempts']--) {
         if (null !== $error) {
             $this->logBlock($error->getMessage(), 'ERROR');
         }
         $value = $this->ask($question, $options['style'], null);
         try {
             return $validator->clean($value);
         } catch (sfValidatorError $error) {
         }
     }
     throw $error;
 }
开发者ID:yuxw75,项目名称:Surrogate,代码行数:42,代码来源:sfTask.class.php


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