r73696 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73695‎ | r73696 | r73697 >
Date:00:04, 25 September 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.4 - follow up to r73672
Modified paths:
  • /trunk/extensions/Validator/includes/ItemParameterManipualtion.php (modified) (history)
  • /trunk/extensions/Validator/includes/manipulations/ParamManipualtionBoolean.php (added) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/manipulations/ParamManipualtionBoolean.php
@@ -0,0 +1,34 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter manipulation converting the value to a boolean.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file ParamManipulationBoolean.php
 10+ * @ingroup Validator
 11+ * @ingroup ParameterManipulations
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class ParamManipulationBoolean extends ItemParameterManipulation {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct() {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ItemParameterManipulation::doManipulation
 28+ *
 29+ * @since 0.4
 30+ */
 31+ public function doManipulation( &$value, array &$parameters ) {
 32+ $value = in_array( $value, array( 'yes', 'on' ) );
 33+ }
 34+
 35+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/manipulations/ParamManipualtionBoolean.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: trunk/extensions/Validator/includes/ItemParameterManipualtion.php
@@ -16,6 +16,18 @@
1717 abstract class ItemParameterManipulation extends ParameterManipulation {
1818
1919 /**
 20+ * Manipulate an actual value.
 21+ *
 22+ * @param string $value
 23+ * @param array $parameters
 24+ *
 25+ * @since 0.4
 26+ *
 27+ * @return mixed
 28+ */
 29+ protected abstract function doManipulation( &$value, array &$parameters );
 30+
 31+ /**
2032 * Constructor.
2133 *
2234 * @since 0.4
@@ -30,5 +42,23 @@
3143 public function isForLists() {
3244 return false;
3345 }
 46+ /**
 47+ * Validate a parameter against the criterion.
 48+ *
 49+ * @param Parameter $parameter
 50+ * @param array $parameters
 51+ *
 52+ * @since 0.4
 53+ */
 54+ public abstract function manipulate( Parameter &$parameter, array &$parameters ) {
 55+ if ( is_array( $parameter->value ) ) {
 56+ foreach ( $parameter->value as &$item ) {
 57+ $this->doManipulation( $item, $parameters );
 58+ }
 59+ }
 60+ else {
 61+ $this->doManipulation( $parameter->value, $parameters );
 62+ }
 63+ }
3464
3565 }
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r73672CHanges for 0.4 - work on parameter manipulation classesjeroendedauw18:48, 24 September 2010

Status & tagging log