예제 #1
0
 public function testMethod_setRequestMethod()
 {
     $this->request->setRequestMethod('BUTTHEAD');
     $this->assertEqual('BUTTHEAD', HttpRequest::getRequestMethod());
 }
예제 #2
0
파일: Form.php 프로젝트: ksst/kf
 /**
  * Set Values to Form.
  *
  * An associative array is used to pre-populate form elements.
  * The keys of this array correspond with the element names.
  *
  * There are two use cases for this method:
  * 1) pre-filled form
  *    Some default values are set to the form, which then get altered by the user.
  * b) incomming post data
  *    Set the incomming POST data values are set to the form for validation.
  *
  * @param object|array $data Object or Array. If null (default), POST parameters are used.
  */
 public function setValues($data = null)
 {
     // because $data might be an object, typecast $data object to array
     if (is_object($data)) {
         $data = (array) $data;
     }
     if (null === $data) {
         // fetch data from POST
         if ('POST' === \Koch\Http\HttpRequest::getRequestMethod()) {
             $data = \Koch\Http\HttpRequest::getPost();
         }
     }
     // now we got an $data array to populate all the formelements with (setValue)
     foreach ($data as $key => $value) {
         foreach ($this->formelements as $formelement) {
             /*
              * Exclude some formelements from setValue() by type, e.g. Buttons, etc.
              * Setting the value would just change the visible "name" of these elements.
              */
             $type = $formelement->getType();
             if (true === in_array($type, ['submit', 'button', 'cancelbutton', 'resetbutton'], true)) {
                 continue;
             }
             // data[key] and formelement[name] have to match
             //if ($formelement->getName() == ucfirst($key)) {
             $formelement->setValue($value);
             //}
         }
     }
 }
예제 #3
0
파일: TargetRoute.php 프로젝트: ksst/kf
 public static function getRequestMethod()
 {
     return HttpRequest::getRequestMethod();
 }