Esempio n. 1
0
 /**
  * Constructor.
  * 
  * @since 0.4.6
  * 
  * @param IParamDefinition|Parameter|array $param
  * @param mixed $currentValue
  */
 public function __construct($param, $currentValue = false)
 {
     if ($param instanceof IParamDefinition) {
         $this->param = $param;
     } elseif (is_array($param)) {
         $this->param = ParamDefinition::newFromArray($param);
     } else {
         // Compat code, will go in 0.7
         $this->param = ParamDefinition::newFromParameter($param);
     }
     $this->currentValue = $currentValue;
     $this->inputName = $param->getName();
     $this->inputClass = '';
 }
Esempio n. 2
0
 /**
  * Returns a cleaned version of the list of parameter definitions.
  * This includes having converted all supported definition types to
  * ParamDefinition classes and having all keys set to the names of the
  * corresponding parameters.
  *
  *
  * @since 0.5
  *
  * @param $definitions array of IParamDefinition
  *
  * @return array
  * @throws MWException
  */
 public static function getCleanDefinitions(array $definitions)
 {
     $cleanList = array();
     foreach ($definitions as $key => $definition) {
         if (is_array($definition)) {
             if (!array_key_exists('name', $definition) && is_string($key)) {
                 $definition['name'] = $key;
             }
             $definition = ParamDefinition::newFromArray($definition);
         } elseif ($definition instanceof Parameter) {
             // This if for backwards compat, will be removed in 0.7.
             $definition = ParamDefinition::newFromParameter($definition);
         }
         if (!$definition instanceof ParamDefinition) {
             throw new MWException('$definition not an instance of ParamDefinition');
         }
         $cleanList[$definition->getName()] = $definition;
     }
     return $cleanList;
 }