コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: Front.php プロジェクト: nstapelbroek/Glitch_Lib
 /**
  * Set router class/object
  *
  * Set the router object.  The router is responsible for mapping
  * the request to a controller and action.
  *
  * If a class name is provided, instantiates router with any parameters
  * registered via {@link setParam()} or {@link setParams()}.
  *
  * @param string|Zend_Controller_Router_Interface optional $router
  * @throws Zend_Controller_Exception if invalid router class
  * @return Zend_Controller_Front
  */
 public function setRouter($router = null)
 {
     if ($router == null) {
         $router = new Zend_Controller_Router_Rewrite();
     }
     return parent::setRouter($router);
 }
コード例 #3
0
ファイル: Initializer.php プロジェクト: baphled/boodah
 /**
  * Initialize routes
  * 
  * @return void
  */
 public function initRoutes()
 {
     $news = array('module' => 'default', 'controller' => 'news', 'action' => 'topic');
     $tags = array('module' => 'default', 'controller' => 'blog', 'action' => 'tag');
     $milestones = array('module' => 'default', 'controller' => 'tracking', 'action' => 'milestone');
     $projects = array('module' => 'default', 'controller' => 'projects', 'action' => 'info');
     $tweets = array('module' => 'default', 'controller' => 'social', 'action' => 'tweets');
     $ticket = array('module' => 'default', 'controller' => 'tracking', 'action' => 'ticket');
     $tickets = array('module' => 'default', 'controller' => 'tracking', 'action' => 'tickets');
     $newsRoute = new Zend_Controller_Router_Route('/news/topic/:topic', $news);
     $tagsRoute = new Zend_Controller_Router_Route('/blog/tag/:tag', $tags);
     $milestonesRoute = new Zend_Controller_Router_Route('/tracking/milestone/:milestone', $milestones);
     $projectsRoute = new Zend_Controller_Router_Route('/projects/info/:project', $projects);
     $ticketRoute = new Zend_Controller_Router_Route('/tracking/milestone/:milestone/ticket/:ticket', $ticket);
     $ticketsRoute = new Zend_Controller_Router_Route('/tracking/milestone/:milestone/tickets', $tickets);
     $tweetsRoute = new Zend_Controller_Router_Route('/social/tweets/:tweet', $tweets);
     $router = $this->_front->getRouter();
     $router->addRoute('topic', $newsRoute);
     $router->addRoute('tag', $tagsRoute);
     $router->addRoute('milestone', $milestonesRoute);
     $router->addRoute('ticket', $ticketRoute);
     $router->addRoute('ticket-milestone', $ticketsRoute);
     $router->addRoute('project', $projectsRoute);
     $router->addRoute('tweet', $tweetsRoute);
     $this->_front->setRouter($router);
 }
コード例 #4
0
 public function testUsingFrontController()
 {
     $controller = new Zend_Controller_Front();
     $controller->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files');
     $request = new Zend_Controller_Request_Http('http://framework.zend.com/empty');
     $controller->setResponse(new Zend_Controller_Response_Cli());
     $controller->setRouter(new Zend_Controller_Router());
     $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin();
     $controller->registerPlugin($plugin);
     $response = $controller->dispatch($request);
     $this->assertEquals('123456', $response->getBody());
     $this->assertEquals('123456', $plugin->getResponse()->getBody());
 }
コード例 #5
0
ファイル: App.php プロジェクト: riteshsahu1981/Weadvance
 /**
  * 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);
 }
コード例 #6
0
ファイル: Task.php プロジェクト: jorgenils/zend-framework
 /**
  * Dispatches all requests. 
  *
  * @param  Zend_Controller_Front $controller
  * @return array|null Array of Response objects, or null if no tasks
  */
 public function run(Zend_Controller_Front $controller)
 {
     $router = $controller->getRouter();
     $returnResponse = $controller->returnResponse();
     $responses = array();
     foreach ($this->_requests as $request) {
         if ($request->getControllerName()) {
             // Use default router
             $controller->setRouter(new Zend_Controller_Router());
         }
         if ($returnResponse) {
             $responses[] = $controller->dispatch($request);
         }
         $controller->setRouter($router);
     }
     $this->_completed = true;
     return $responses;
 }