当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Controller_Front::setRequest方法代码示例

本文整理汇总了PHP中Zend_Controller_Front::setRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Front::setRequest方法的具体用法?PHP Zend_Controller_Front::setRequest怎么用?PHP Zend_Controller_Front::setRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Controller_Front的用法示例。


在下文中一共展示了Zend_Controller_Front::setRequest方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doRequest

 public function doRequest($request)
 {
     // redirector should not exit
     $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $redirector->setExit(false);
     // json helper should not exit
     $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $zendRequest = new \Zend_Controller_Request_HttpTestCase();
     $zendRequest->setMethod($request->getMethod());
     $zendRequest->setCookies($request->getCookies());
     $zendRequest->setParams($request->getParameters());
     // Sf2's BrowserKit does not distinguish between GET, POST, PUT etc.,
     // so we set all parameters in ZF's request here to not break apps
     // relying on $request->getPost()
     $zendRequest->setPost($request->getParameters());
     $zendRequest->setRawBody($request->getContent());
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($this->extractHeaders($request));
     $_FILES = $this->remapFiles($request->getFiles());
     $_SERVER = array_merge($_SERVER, $request->getServer());
     $zendResponse = new \Zend_Controller_Response_HttpTestCase();
     $this->front->setRequest($zendRequest)->setResponse($zendResponse);
     ob_start();
     try {
         $this->bootstrap->run();
     } catch (\Exception $e) {
         ob_end_clean();
         throw $e;
     }
     ob_end_clean();
     $this->zendRequest = $zendRequest;
     $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $this->formatResponseHeaders($zendResponse));
     return $response;
 }
开发者ID:kansey,项目名称:yii2albom,代码行数:35,代码来源:ZF1.php

示例2: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->front = \Zend\Controller\Front::getInstance();
     $this->front->resetInstance();
     $this->request = new Request\Http();
     $this->front->setRequest($this->request);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:13,代码来源:ActionStackTest.php

示例3: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->front = Zend_Controller_Front::getInstance();
     $this->front->resetInstance();
     $this->request = new Zend_Controller_Request_Http();
     $this->front->setRequest($this->request);
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:13,代码来源:ActionStackTest.php

示例4: doRequest

 public function doRequest($request)
 {
     // redirector should not exit
     $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $redirector->setExit(false);
     // json helper should not exit
     $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $zendRequest = new \Zend_Controller_Request_HttpTestCase();
     $zendRequest->setMethod($request->getMethod());
     $zendRequest->setCookies($request->getCookies());
     $zendRequest->setParams($request->getParameters());
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($request->getServer());
     $_FILES = $request->getFiles();
     $_SERVER = array_merge($_SERVER, $request->getServer());
     $zendResponse = new \Zend_Controller_Response_HttpTestCase();
     $this->front->setRequest($zendRequest)->setResponse($zendResponse);
     ob_start();
     $this->bootstrap->run();
     ob_end_clean();
     $this->zendRequest = $zendRequest;
     $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $zendResponse->getHeaders());
     return $response;
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:25,代码来源:ZF1.php

示例5: tearDown

 protected function tearDown()
 {
     if (null !== $this->_oldRequest) {
         $this->_front->setRequest($this->_oldRequest);
     } else {
         $this->_front->setRequest(new Zend_Controller_Request_Http());
     }
     $this->_front->setRouter($this->_oldRouter);
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:9,代码来源:MvcTest.php

示例6: __construct

 /**
  * Sets up all the initial required pieces of the app.
  * 
  * @param string $environment
  * @param string $appPath
  * @param string $moduleDir
  */
 public function __construct($environment, $appPath = APPLICATION_PATH, $moduleDir = 'modules')
 {
     // set the environment
     $this->_environment = (string) $environment;
     // set the application path
     $this->_appPath = $appPath;
     // set the modules dir path
     $this->_moduleDir = $this->_appPath . DIRECTORY_SEPARATOR . $moduleDir;
     // initiate autoloader
     require_once 'Zend/Loader/Autoloader.php';
     $this->_autoloader = Zend_Loader_Autoloader::getInstance();
     // set up module autoloading
     $this->_autoloader->pushAutoloader(array($this, 'moduleAutoload'));
     // set front controller
     $this->_front = Zend_Controller_Front::getInstance();
     // add module directory
     $this->_front->addModuleDirectory($this->_moduleDir);
     // initiate request
     if ($this->_request === null) {
         $this->_request = new Zend_Controller_Request_Http();
     }
     // initiate response
     if ($this->_response === null) {
         $this->_response = new Zend_Controller_Response_Http();
     }
     // initiate router (Zend_Controller_Router_Rwrite)
     $this->_router = $this->_front->getRouter();
     // get application.ini options
     $appOptions = $this->_getApplicationOptions();
     // set routes in router from application.ini (if any)
     $this->_addRoutesFromConfig($appOptions);
     // update request with routes
     $this->_route($this->_request);
     // get module options
     $moduleOptions = $this->_getModuleOptions();
     // merge application and module options into one array
     $options = $this->mergeOptions($appOptions, $moduleOptions);
     // set options
     $this->setOptions($options);
     // update front controller request
     $this->_front->setRequest($this->_request);
     // update front controller response
     $this->_front->setResponse($this->_response);
     // to be used in dispatch
     $this->_front->setRouter($this->_router);
 }
开发者ID:riteshsahu1981,项目名称:Weadvance,代码行数:53,代码来源:App.php

示例7: testHelperPullsResponseFromFrontControllerWithNoRegisteredActionController

 public function testHelperPullsResponseFromFrontControllerWithNoRegisteredActionController()
 {
     $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     $this->assertNull($helper->getActionController());
     $aRequest = new Zend_Controller_Request_Http();
     $aRequest->setModuleName('default')->setControllerName('zend_controller_action_helper-broker')->setActionName('index');
     $aResponse = new Zend_Controller_Response_Cli();
     $fRequest = new Zend_Controller_Request_Http();
     $fRequest->setModuleName('foo')->setControllerName('foo-bar')->setActionName('baz');
     $fResponse = new Zend_Controller_Response_Cli();
     $this->front->setRequest($fRequest)->setResponse($fResponse);
     $hRequest = $helper->getRequest();
     $this->assertNotSame($hRequest, $aRequest);
     $this->assertSame($hRequest, $fRequest);
     $hResponse = $helper->getResponse();
     $this->assertNotSame($hResponse, $aResponse);
     $this->assertSame($hResponse, $fResponse);
 }
开发者ID:sasezaki,项目名称:mirror-zf1-tests,代码行数:18,代码来源:HelperBrokerTest.php

示例8: _processRequestStack

 /**
  * Processes the requestStack and merges their responses into $response.
  *
  * @param Zend_Controller_Front $front
  * @param Zend_Controller_Response_Abstract $response
  *
  */
 protected function _processRequestStack($front, Zend_Controller_Response_Abstract $response)
 {
     $stack =& $this->_requestStack;
     $config =& $this->_config;
     $i = count($stack) - 1;
     $responseStack = array();
     $front->returnResponse(true);
     do {
         $myResponse = new Zend_Controller_Response_Http();
         $nextRequest = array_pop($stack);
         $nextRequest->setParam($config['indexKey'], $i);
         $this->_resetHelper();
         $this->_resetPlugins();
         $this->_resetParams($nextRequest->getParams());
         $front->setRequest($nextRequest);
         $front->setResponse($myResponse);
         $responseStack[] = $front->dispatch($nextRequest, $myResponse);
     } while ($i--);
     $front->returnResponse(false);
     $bodies = array();
     for ($i = 0, $len = count($responseStack); $i < $len; $i++) {
         $bodies[] = $responseStack[$i]->getBody();
     }
     $body = implode(',', $bodies);
     $response->setBody('[' . $body . ']');
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:33,代码来源:ExtRequest.php

示例9: routeToApi

 /**
  * Route to APImodule
  * @param \Zend_Controller_Front $front
  */
 private function routeToApi(\Zend_Controller_Front $front)
 {
     $errorPlugin = new \Zend_Controller_Plugin_ErrorHandler();
     $errorPlugin->setErrorHandlerController(BaseRouter::DEFAULT_ERROR_CONTROLLER);
     $errorPlugin->setErrorHandlerAction(BaseRouter::DEFAULT_ERROR_ACTION);
     $errorPlugin->setErrorHandlerModule(ApiRouter::API_MODULE);
     $front->setParam('noViewRenderer', true);
     $front->setRequest(new ApiRequest())->setRouter(new ApiRouter())->registerPlugin($errorPlugin);
 }
开发者ID:cipherpols,项目名称:cze,代码行数:13,代码来源:Base.php


注:本文中的Zend_Controller_Front::setRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。