コード例 #1
0
ファイル: ParameterInput.php プロジェクト: Tjorriemorrie/app
 /**
  * Returns the HTML for the parameter input.
  * 
  * @since 0.4.6
  * 
  * @return string
  */
 public function getHtml()
 {
     $valueList = array();
     if (is_array($this->param->getAllowedValues())) {
         $valueList[] = $this->param->getAllowedValues();
     }
     // Compat code, will got in 0.7
     foreach ($this->param->getCriteria() as $criterion) {
         if ($criterion instanceof CriterionInArray) {
             $valueList[] = $criterion->getAllowedValues();
         }
     }
     if (count($valueList) > 0) {
         // Compat code, will got in 0.7
         $valueList = count($valueList) > 1 ? call_user_func_array('array_intersect', $valueList) : $valueList[0];
         $html = $this->param->isList() ? $this->getCheckboxListInput($valueList) : $this->getSelectInput($valueList);
     } else {
         switch ($this->param->getType()) {
             case Parameter::TYPE_CHAR:
             case Parameter::TYPE_FLOAT:
             case Parameter::TYPE_INTEGER:
             case Parameter::TYPE_NUMBER:
                 $html = $this->getNumberInput();
                 break;
             case Parameter::TYPE_BOOLEAN:
                 $html = $this->getBooleanInput();
                 break;
             case Parameter::TYPE_STRING:
             default:
                 $html = $this->getStrInput();
                 break;
         }
     }
     return $html;
 }
コード例 #2
0
ファイル: Param.php プロジェクト: Tjorriemorrie/app
 /**
  * Validates the provided value against all criteria.
  *
  * @deprecated removal in 0.7
  * @since 0.5
  *
  * @param $definitions array of ParamDefinition
  * @param $params array of Param
  */
 protected function validateCriteria(array $definitions, array $params)
 {
     $parameter = $this->toParameter();
     foreach ($this->definition->getCriteria() as $criterion) {
         $validationResult = $criterion->validate($parameter, $params);
         if (!$validationResult->isValid()) {
             $this->handleValidationError($validationResult);
             if (!self::$accumulateParameterErrors || $this->hasFatalError()) {
                 break;
             }
         }
     }
 }