[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * This file is part of the symfony package. 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * (c) 2004-2006 Sean Kerr. 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 /** 13 * sfValidator allows you to apply constraints to user entered parameters. 14 * 15 * @package symfony 16 * @subpackage validator 17 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 18 * @author Sean Kerr <skerr@mojavi.org> 19 * @version SVN: $Id: sfValidator.class.php 3250 2007-01-12 20:09:11Z fabien $ 20 */ 21 abstract class sfValidator 22 { 23 protected 24 $parameterHolder = null, 25 $context = null; 26 27 /** 28 * Executes this validator. 29 * 30 * @param mixed A file or parameter value/array 31 * @param string An error message reference 32 * 33 * @return bool true, if this validator executes successfully, otherwise false 34 */ 35 abstract function execute(&$value, &$error); 36 37 /** 38 * Retrieves the current application context. 39 * 40 * @return sfContext The current sfContext instance 41 */ 42 public final function getContext() 43 { 44 return $this->context; 45 } 46 47 /** 48 * Initializes this validator. 49 * 50 * @param sfContext The current application context 51 * @param array An associative array of initialization parameters 52 * 53 * @return bool true, if initialization completes successfully, otherwise false 54 */ 55 public function initialize($context, $parameters = array()) 56 { 57 $this->context = $context; 58 59 $this->parameterHolder = new sfParameterHolder(); 60 $this->parameterHolder->add($parameters); 61 62 return true; 63 } 64 65 /** 66 * Retrieves the parameters from the validator. 67 * 68 * @return sfParameterHolder List of parameters 69 */ 70 public function getParameterHolder() 71 { 72 return $this->parameterHolder; 73 } 74 75 /** 76 * Retrieves a parameter from the validator. 77 * 78 * @param string Parameter name 79 * @param mixed A default parameter value 80 * @param string A parameter namespace 81 * 82 * @return mixed A parameter value 83 */ 84 public function getParameter($name, $default = null, $ns = null) 85 { 86 return $this->parameterHolder->get($name, $default, $ns); 87 } 88 89 /** 90 * Indicates whether or not a parameter exist for the validator. 91 * 92 * @param string A parameter name 93 * @param string A parameter namespace 94 * 95 * @return boolean true, if parameter exists, otherwise false 96 */ 97 public function hasParameter($name, $ns = null) 98 { 99 return $this->parameterHolder->has($name, $ns); 100 } 101 102 /** 103 * Sets a parameter for the validator. 104 * 105 * @param string A parameter name 106 * @param mixed A parameter value 107 * @param string A parameter namespace 108 */ 109 public function setParameter($name, $value, $ns = null) 110 { 111 $this->parameterHolder->set($name, $value, $ns); 112 } 113 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |