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


PHP Dispatcher::getUrl方法代码示例

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


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

示例1: startActionForTest

 /**
  * Starts the process for the given $url.
  * 
  * @param string $url Requested URL
  * @param array $params Settings array ("bare", "return") which is
  *              melded with the GET and POST params
  * @return mixed The results of the called action
  */
 public function startActionForTest($url, $params = array())
 {
     $default = array('fixturize' => false, 'data' => array(), 'method' => 'get', 'connection' => 'default');
     $params = array_merge($default, $params);
     $toSave = array('case' => null, 'group' => null, 'app' => null, 'output' => null, 'show' => null, 'plugin' => null);
     $this->__savedGetData = empty($this->__savedGetData) ? array_intersect_key($_GET, $toSave) : $this->__savedGetData;
     $data = !empty($params['data']) ? $params['data'] : array();
     if (strtolower($params['method']) == 'get') {
         $_GET = array_merge($this->__savedGetData, $data);
         $_POST = array();
     } else {
         $_POST = array('data' => $data);
         $_GET = $this->__savedGetData;
     }
     $_SERVER['REQUEST_METHOD'] = strtoupper($params['method']);
     $params = array_diff_key($params, array('data' => null, 'method' => null));
     $Dispatcher = new Dispatcher();
     $url = $Dispatcher->getUrl($url);
     $this->params = array_merge($Dispatcher->parseParams($url), $params);
     $this->here = $this->base . '/' . $url;
     Router::setRequestInfo(array($this->params, array('base' => $this->base, 'here' => $this->here, 'webroot' => $this->webroot)));
     $this->base = $this->base;
     $this->here = $this->here;
     $this->plugin = isset($this->params['plugin']) ? $this->params['plugin'] : null;
     $this->action =& $this->params['action'];
     $this->passedArgs = array_merge($this->params['pass'], $this->params['named']);
     if (!empty($this->params['data'])) {
         $this->data =& $this->params['data'];
     } else {
         $this->data = null;
     }
     if (!empty($this->params['bare'])) {
         $this->autoLayout = false;
     }
     if (isset($this->_testCase) && method_exists($this->_testCase, 'startController')) {
         $this->_testCase->startController($this, $this->params);
     }
     unset($_SESSION);
     $this->constructClasses();
     $this->startupProcess();
 }
开发者ID:joelmoss,项目名称:cakephp-callbacks,代码行数:49,代码来源:test_controller.php

示例2: testGetUrl

 /**
  * testGetUrl method
  *
  * @return void
  * @access public
  */
 function testGetUrl()
 {
     $Dispatcher = new Dispatcher();
     $Dispatcher->base = '/app/webroot/index.php';
     $uri = '/app/webroot/index.php/posts/add';
     $result = $Dispatcher->getUrl($uri);
     $expected = 'posts/add';
     $this->assertEqual($expected, $result);
     Configure::write('App.baseUrl', '/app/webroot/index.php');
     $uri = '/posts/add';
     $result = $Dispatcher->getUrl($uri);
     $expected = 'posts/add';
     $this->assertEqual($expected, $result);
     $_GET['url'] = array();
     Configure::write('App.base', '/control');
     $Dispatcher = new Dispatcher();
     $Dispatcher->baseUrl();
     $uri = '/control/students/browse';
     $result = $Dispatcher->getUrl($uri);
     $expected = 'students/browse';
     $this->assertEqual($expected, $result);
     $_GET['url'] = array();
     $Dispatcher = new Dispatcher();
     $Dispatcher->base = '';
     $uri = '/?/home';
     $result = $Dispatcher->getUrl($uri);
     $expected = '?/home';
     $this->assertEqual($expected, $result);
 }
开发者ID:robksawyer,项目名称:cakephp2x,代码行数:35,代码来源:dispatcher.test.php


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