Development

/branches/1.3/lib/validator/sfValidatorCallback.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/validator/sfValidatorCallback.class.php

Revision 9048, 1.3 kB (checked in by FabianLange, 7 years ago)

1.1: fixed @param phpdoc to fit specs in validator (refs #2991)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfValidatorCallback validates an input value if the given callback does not throw a sfValidatorError.
13  *
14  * @package    symfony
15  * @subpackage validator
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfValidatorCallback extends sfValidatorBase
20 {
21   /**
22    * Configures the current validator.
23    *
24    * Available options:
25    *
26    *  * callback:  A valid PHP callback (required)
27    *  * arguments: An array of arguments to pass to the callback
28    *
29    * @param array $options    An array of options
30    * @param array $messages   An array of error messages
31    *
32    * @see sfValidatorBase
33    */
34   protected function configure($options = array(), $messages = array())
35   {
36     $this->addRequiredOption('callback');
37     $this->addOption('arguments', array());
38
39     $this->setOption('required', false);
40   }
41
42   /**
43    * @see sfValidatorBase
44    */
45   protected function doClean($value)
46   {
47     return call_user_func($this->getOption('callback'), $this, $value, $this->getOption('arguments'));
48   }
49 }
50
Note: See TracBrowser for help on using the browser.