| 1 |
lars |
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: sfValidatorCallback.class.php 9048 2008-05-19 09:11:23Z FabianLange $
|
|
|
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 |
}
|