Index: trunk/extensions/Validator/includes/manipulations/ParamManipulationImplode.php |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | * @since 0.4 |
51 | 51 | */ |
52 | 52 | public function manipulate( Parameter &$parameter, array &$parameters ) { |
53 | | - $parameter->value = $this->wrapper . implode( $this->wrapper . $this->delimiter . $this->wrapper, $parameter->value ) . $this->wrapper; |
| 53 | + $parameter->setValue( $this->wrapper . implode( $this->wrapper . $this->delimiter . $this->wrapper, $parameter->getValue() ) . $this->wrapper ); |
54 | 54 | } |
55 | 55 | |
56 | 56 | } |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/ItemParameterCriterion.php |
— | — | @@ -79,15 +79,15 @@ |
80 | 80 | public function validate( Parameter $parameter ) { |
81 | 81 | $result = new CriterionValidationResult(); |
82 | 82 | |
83 | | - if ( is_array( $parameter->value ) ) { |
84 | | - foreach ( $parameter->value as $item ) { |
| 83 | + if ( is_array( $parameter->getValue() ) ) { |
| 84 | + foreach ( $parameter->getValue() as $item ) { |
85 | 85 | if ( !$this->doValidation( $item ) ) { |
86 | 86 | $result->addInvalidItem( $item ); |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | 90 | if ( $result->hasInvalidItems() ) { |
91 | | - $allInvalid = count( $result->getInvalidItems() ) == count( $parameter->value ); |
| 91 | + $allInvalid = count( $result->getInvalidItems() ) == count( $parameter->getValue() ); |
92 | 92 | |
93 | 93 | // If the parameter is required and all items are invalid, it's fatal. |
94 | 94 | // Else it's high for required, and normal for non-required parameters. |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | } |
109 | 109 | } |
110 | 110 | else { |
111 | | - if ( !$this->doValidation( $parameter->value ) ) { |
| 111 | + if ( !$this->doValidation( $parameter->getValue() ) ) { |
112 | 112 | $result->addError( |
113 | 113 | new ValidationError( |
114 | 114 | $this->getItemErrorMessage( $parameter ), |
Index: trunk/extensions/Validator/includes/ItemParameterManipulation.php |
— | — | @@ -51,13 +51,14 @@ |
52 | 52 | * @since 0.4 |
53 | 53 | */ |
54 | 54 | public function manipulate( Parameter &$parameter, array &$parameters ) { |
55 | | - if ( is_array( $parameter->value ) ) { |
56 | | - foreach ( $parameter->value as &$item ) { |
| 55 | + if ( is_array( $parameter->getValue() ) ) { |
| 56 | + $value = &$parameter->getValue(); |
| 57 | + foreach ( $value as &$item ) { |
57 | 58 | $this->doManipulation( $item, $parameters ); |
58 | 59 | } |
59 | 60 | } |
60 | 61 | else { |
61 | | - $this->doManipulation( $parameter->value, $parameters ); |
| 62 | + $this->doManipulation( $parameter->getValue(), $parameters ); |
62 | 63 | } |
63 | 64 | } |
64 | 65 | |
Index: trunk/extensions/Validator/includes/Parameter.php |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | * |
57 | 57 | * @var array |
58 | 58 | */ |
59 | | - public $dependencies = array(); |
| 59 | + protected $dependencies = array(); |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * The default value for the parameter, or null when the parameter is required. |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | * |
66 | 66 | * @var mixed |
67 | 67 | */ |
68 | | - public $default; |
| 68 | + protected $default; |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * The main name of the parameter. |
— | — | @@ -134,13 +134,11 @@ |
135 | 135 | /** |
136 | 136 | * The value of the parameter. |
137 | 137 | * |
138 | | - * TODO: protected |
139 | | - * |
140 | 138 | * @since 0.4 |
141 | 139 | * |
142 | 140 | * @var mixed |
143 | 141 | */ |
144 | | - public $value; |
| 142 | + protected $value; |
145 | 143 | |
146 | 144 | /** |
147 | 145 | * Keeps track of how many times the parameter has been set by the user. |
— | — | @@ -263,7 +261,7 @@ |
264 | 262 | } |
265 | 263 | |
266 | 264 | if ( array_key_exists( 'dependencies', $definition ) ) { |
267 | | - $parameter->dependencies = (array)$definition['dependencies']; |
| 265 | + $parameter->addDependencies( $definition['dependencies'] ); |
268 | 266 | } |
269 | 267 | |
270 | 268 | return $parameter; |
— | — | @@ -335,6 +333,19 @@ |
336 | 334 | } |
337 | 335 | |
338 | 336 | /** |
| 337 | + * Adds one or more dependencies. There are the names of parameters |
| 338 | + * that need to be validated and formatted before this one. |
| 339 | + * |
| 340 | + * @since 0.4 |
| 341 | + * |
| 342 | + * @return array |
| 343 | + */ |
| 344 | + public function addDependencies() { |
| 345 | + $args = func_get_args(); |
| 346 | + $this->dependencies = array_merge( $this->dependencies, is_array( $args[0] ) ? $args[0] : $args ); |
| 347 | + } |
| 348 | + |
| 349 | + /** |
339 | 350 | * Adds one or more ParameterManipulation. |
340 | 351 | * |
341 | 352 | * @since 0.4 |
— | — | @@ -386,6 +397,17 @@ |
387 | 398 | } |
388 | 399 | |
389 | 400 | /** |
| 401 | + * Sets the value. |
| 402 | + * |
| 403 | + * @since 0.4 |
| 404 | + * |
| 405 | + * @param mixed $value |
| 406 | + */ |
| 407 | + public function setValue( $value ) { |
| 408 | + $this->value = $value; |
| 409 | + } |
| 410 | + |
| 411 | + /** |
390 | 412 | * Sets the $value to a cleaned value of $originalValue. |
391 | 413 | * |
392 | 414 | * @since 0.4 |
— | — | @@ -517,7 +539,7 @@ |
518 | 540 | */ |
519 | 541 | public function getDependencies() { |
520 | 542 | return $this->dependencies; |
521 | | - } |
| 543 | + } |
522 | 544 | |
523 | 545 | /** |
524 | 546 | * Returns the original use-provided name. |