コード例 #1
0
 /**
  * Tests WindFrontController->registeComponent()
  * 
  */
 public function testRegisteComponent()
 {
     $httprequest = new WindHttpRequest();
     $httprequest->setAttribute(123, 'long');
     $httpresponse = new WindHttpResponse();
     $httpresponse->setData(123, 'long');
     $aaa = new stdClass();
     $aaa->long = 123;
     $this->WindFrontController->registeComponent($aaa, 'aaa');
     $this->WindFrontController->registeComponent($httpresponse, 'response');
     $this->WindFrontController->registeComponent($httprequest, 'request');
     $this->WindFrontController->createApplication();
     $this->assertEquals(123, Wind::getApp()->getRequest()->getAttribute('long'));
     $this->assertEquals(123, Wind::getApp()->getResponse()->getData('long'));
     $this->assertEquals(123, Wind::getApp()->getComponent('aaa')->long);
 }
コード例 #2
0
 /**
  * 设置全局变量
  *
  * @param array|object|string $data        	
  * @param string $key        	
  * @return void
  */
 public function setGlobal($data, $key = '')
 {
     if ($key) {
         $_G[$key] = $data;
     } else {
         if (is_object($data)) {
             $data = get_object_vars($data);
         }
         $_G = $data;
     }
     $this->response->setData($_G, 'G', true);
 }
コード例 #3
0
 /**
  * @see IWindRequest::getResponse()
  * @return WindHttpResponse
  */
 public function getResponse()
 {
     $response = new WindHttpResponse();
     $response->setHeader('Content-type', 'text/html;charset=utf8');
     return $response;
 }