Development

/branches/1.1/lib/plugins/sfCompat10Plugin/lib/validator/sfValidator.class.php

You must first sign up to be able to contribute.

root/branches/1.1/lib/plugins/sfCompat10Plugin/lib/validator/sfValidator.class.php

Revision 10270, 2.9 kB (checked in by Carl.Vondrick, 6 years ago)

1.1: added deprecated warnings to all sfCompatPlugin classes (closes #3882)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
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 <sean@code-box.org>
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  * sfValidatorBase allows you to apply constraints to user entered parameters.
14  *
15  * WARNING: This class is deprecated and will be removed in symfony 1.2.
16  *
17  * @package    symfony
18  * @subpackage validator
19  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
20  * @author     Sean Kerr <sean@code-box.org>
21  * @version    SVN: $Id$
22  * @deprecated Deprecated since symfony 1.1
23  */
24 abstract class sfValidator
25 {
26   protected
27     $parameterHolder = null,
28     $context         = null;
29
30   /**
31    * Class constructor.
32    *
33    * @see initialize()
34    */
35   public function __construct($context, $parameters = array())
36   {
37     $this->initialize($context, $parameters);
38   }
39
40   /**
41    * Initializes this validator.
42    *
43    * @param sfContext The current application context
44    * @param array   An associative array of initialization parameters
45    *
46    * @return bool true, if initialization completes successfully, otherwise false
47    */
48   public function initialize($context, $parameters = array())
49   {
50     $this->context = $context;
51
52     $this->parameterHolder = new sfParameterHolder();
53     $this->parameterHolder->add($parameters);
54
55     return true;
56   }
57
58   /**
59    * Executes this validator.
60    *
61    * @param mixed A file or parameter value/array
62    * @param string An error message reference
63    *
64    * @return bool true, if this validator executes successfully, otherwise false
65    */
66   abstract function execute(&$value, &$error);
67
68   /**
69    * Retrieves the current application context.
70    *
71    * @return sfContext The current sfContext instance
72    */
73   public final function getContext()
74   {
75     return $this->context;
76   }
77
78   /**
79    * Retrieves the parameters from the validator.
80    *
81    * @return sfParameterHolder List of parameters
82    */
83   public function getParameterHolder()
84   {
85     return $this->parameterHolder;
86   }
87
88   /**
89    * Retrieves a parameter from the validator.
90    *
91    * @param string Parameter name
92    * @param mixed A default parameter value
93    *
94    * @return mixed A parameter value
95    */
96   public function getParameter($name, $default = null)
97   {
98     return $this->parameterHolder->get($name, $default);
99   }
100
101   /**
102    * Indicates whether or not a parameter exist for the validator.
103    *
104    * @param string A parameter name
105    *
106    * @return boolean true, if parameter exists, otherwise false
107    */
108   public function hasParameter($name)
109   {
110     return $this->parameterHolder->has($name);
111   }
112
113   /**
114    * Sets a parameter for the validator.
115    *
116    * @param string A parameter name
117    * @param mixed A parameter value
118    */
119   public function setParameter($name, $value)
120   {
121     $this->parameterHolder->set($name, $value);
122   }
123 }
124
Note: See TracBrowser for help on using the browser.