[ 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 * 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 * sfCompareValidator checks the equality of two different request parameters. 13 * 14 * passwordValidator: 15 * class: sfCompareValidator 16 * param: 17 * check: password2 18 * compare_error: The passwords you entered do not match. Please try again. 19 * 20 * @package symfony 21 * @subpackage validator 22 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 23 * @version SVN: $Id: sfCompareValidator.class.php 3233 2007-01-11 21:01:08Z fabien $ 24 */ 25 class sfCompareValidator extends sfValidator 26 { 27 /** 28 * Executes this validator. 29 * 30 * @param mixed A file or parameter value/array 31 * @param error An error message reference 32 * 33 * @return bool true, if this validator executes successfully, otherwise false 34 */ 35 public function execute(&$value, &$error) 36 { 37 $check_param = $this->getParameterHolder()->get('check'); 38 $check_value = $this->getContext()->getRequest()->getParameter($check_param); 39 40 if ($value !== $check_value) 41 { 42 $error = $this->getParameterHolder()->get('compare_error'); 43 return false; 44 } 45 46 return true; 47 } 48 49 public function initialize($context, $parameters = null) 50 { 51 // initialize parent 52 parent::initialize($context); 53 54 // set defaults 55 $this->getParameterHolder()->set('compare_error', 'Invalid input'); 56 57 $this->getParameterHolder()->add($parameters); 58 59 return true; 60 } 61 }
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 |