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


PHP Router::getNamedExpressions方法代码示例

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


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

示例1: parseParams

 /**
  * Returns array of GET and POST parameters. GET parameters are taken from given URL.
  *
  * @param string $fromUrl URL to mine for parameter information.
  * @return array Parameters found in POST and GET.
  * @access public
  */
 function parseParams($fromUrl)
 {
     $params = array();
     if (isset($_POST)) {
         $params['form'] = $_POST;
         if (ini_get('magic_quotes_gpc') === '1') {
             $params['form'] = stripslashes_deep($params['form']);
         }
         if (env('HTTP_X_HTTP_METHOD_OVERRIDE')) {
             $params['form']['_method'] = env('HTTP_X_HTTP_METHOD_OVERRIDE');
         }
         if (isset($params['form']['_method'])) {
             if (!empty($_SERVER)) {
                 $_SERVER['REQUEST_METHOD'] = $params['form']['_method'];
             } else {
                 $_ENV['REQUEST_METHOD'] = $params['form']['_method'];
             }
             unset($params['form']['_method']);
         }
     }
     $namedExpressions = Router::getNamedExpressions();
     extract($namedExpressions);
     include CONFIGS . 'routes.php';
     $params = array_merge(Router::parse($fromUrl), $params);
     if (strlen($params['action']) === 0) {
         $params['action'] = 'index';
     }
     if (isset($params['form']['data'])) {
         $params['data'] = Router::stripEscape($params['form']['data']);
         unset($params['form']['data']);
     }
     if (isset($_GET)) {
         if (ini_get('magic_quotes_gpc') === '1') {
             $url = stripslashes_deep($_GET);
         } else {
             $url = $_GET;
         }
         if (isset($params['url'])) {
             $params['url'] = array_merge($params['url'], $url);
         } else {
             $params['url'] = $url;
         }
     }
     foreach ($_FILES as $name => $data) {
         if ($name != 'data') {
             $params['form'][$name] = $data;
         }
     }
     if (isset($_FILES['data'])) {
         foreach ($_FILES['data'] as $key => $data) {
             foreach ($data as $model => $fields) {
                 if (is_array($fields)) {
                     foreach ($fields as $field => $value) {
                         if (is_array($value)) {
                             foreach ($value as $k => $v) {
                                 $params['data'][$model][$field][$k][$key] = $v;
                             }
                         } else {
                             $params['data'][$model][$field][$key] = $value;
                         }
                     }
                 } else {
                     $params['data'][$model][$key] = $fields;
                 }
             }
         }
     }
     return $params;
 }
开发者ID:Navdeep736,项目名称:regetp01,代码行数:76,代码来源:dispatcher.php

示例2: testNamedArgsUrlGeneration

 /**
  * testNamedArgsUrlGeneration method
  *
  * @access public
  * @return void
  */
 function testNamedArgsUrlGeneration()
 {
     $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 1, 'deleted' => 1));
     $expected = '/posts/index/published:1/deleted:1';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 0, 'deleted' => 0));
     $expected = '/posts/index/published:0/deleted:0';
     $this->assertEqual($result, $expected);
     Router::reload();
     extract(Router::getNamedExpressions());
     Router::connectNamed(array('file' => '[\\w\\.\\-]+\\.(html|png)'));
     Router::connect('/', array('controller' => 'graphs', 'action' => 'index'));
     Router::connect('/:id/*', array('controller' => 'graphs', 'action' => 'view'), array('id' => $ID));
     $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, 'file' => 'asdf.png'));
     $expected = '/12/file:asdf.png';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, 'file' => 'asdf.foo'));
     $expected = '/graphs/view/12/file:asdf.foo';
     $this->assertEqual($result, $expected);
     Configure::write('Routing.admin', 'admin');
     Router::reload();
     Router::setRequestInfo(array(array('admin' => true, 'controller' => 'controller', 'action' => 'index', 'form' => array(), 'url' => array(), 'plugin' => null), array('base' => '/', 'here' => '/', 'webroot' => '/base/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array())));
     Router::parse('/');
     $result = Router::url(array('page' => 1, 0 => null, 'sort' => 'controller', 'direction' => 'asc', 'order' => null));
     $expected = "/admin/controller/index/page:1/sort:controller/direction:asc";
     $this->assertEqual($result, $expected);
     Router::reload();
     Router::setRequestInfo(array(array('admin' => true, 'controller' => 'controller', 'action' => 'index', 'form' => array(), 'url' => array(), 'plugin' => null), array('base' => '/', 'here' => '/', 'webroot' => '/base/', 'passedArgs' => array('type' => 'whatever'), 'argSeparator' => ':', 'namedArgs' => array('type' => 'whatever'))));
     $result = Router::parse('/admin/controller/index/type:whatever');
     $result = Router::url(array('type' => 'new'));
     $expected = "/admin/controller/index/type:new";
     $this->assertEqual($result, $expected);
 }
开发者ID:laiello,项目名称:myopensources,代码行数:39,代码来源:router.test.php

示例3: _loadRoutes

 /**
  * Reloads the routes configuration from app/Config/routes.php, and compiles
  * all routes found
  *
  * @return boolean True if config reload was a success, otherwise false
  */
 protected function _loadRoutes()
 {
     Router::reload();
     extract(Router::getNamedExpressions());
     if (!@(include APP . 'Config' . DS . 'routes.php')) {
         return false;
     }
     CakePlugin::routes();
     Router::parse('/');
     return true;
 }
开发者ID:pritten,项目名称:SmartCitizen.me,代码行数:17,代码来源:ConsoleShell.php

示例4: parseParams

 /**
  * Applies Routing and additionalParameters to the request to be dispatched.
  * If Routes have not been loaded they will be loaded, and app/Config/routes.php will be run.
  *
  * @param CakeRequest $request CakeRequest object to mine for parameter information.
  * @param array $additionalParams An array of additional parameters to set to the request.
  *   Useful when Object::requestAction() is involved
  * @return CakeRequest The request object with routing params set.
  */
 public function parseParams(CakeRequest $request, $additionalParams = array())
 {
     if (count(Router::$routes) == 0) {
         $namedExpressions = Router::getNamedExpressions();
         extract($namedExpressions);
         $this->_loadRoutes();
     }
     $params = Router::parse($request->url);
     $request->addParams($params);
     if (!empty($additionalParams)) {
         $request->addParams($additionalParams);
     }
     return $request;
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:23,代码来源:Dispatcher.php

示例5: testParse

 /**
  * test the parse method of CakeRoute.
  *
  * @return void
  */
 function testParse()
 {
     extract(Router::getNamedExpressions());
     $route =& new CakeRoute('/:controller/:action/:id', array('controller' => 'testing4', 'id' => null), array('id' => $ID));
     $route->compile();
     $result = $route->parse('/posts/view/1');
     $this->assertEqual($result['controller'], 'posts');
     $this->assertEqual($result['action'], 'view');
     $this->assertEqual($result['id'], '1');
     $route =& new Cakeroute('/admin/:controller', array('prefix' => 'admin', 'admin' => 1, 'action' => 'index'));
     $route->compile();
     $result = $route->parse('/admin/');
     $this->assertFalse($result);
     $result = $route->parse('/admin/posts');
     $this->assertEqual($result['controller'], 'posts');
     $this->assertEqual($result['action'], 'index');
 }
开发者ID:aqua777,项目名称:rackdoc,代码行数:22,代码来源:router.test.php

示例6: parseParams

 /**
  * Applies Routing and additionalParameters to the request to be dispatched.
  * If Routes have not been loaded they will be loaded, and app/Config/routes.php will be run.
  *
  * @param CakeEvent $event containing the request, response and additional params
  * @return void
  */
 public function parseParams($event)
 {
     $request = $event->data['request'];
     Router::setRequestInfo($request);
     if (count(Router::$routes) == 0) {
         $namedExpressions = Router::getNamedExpressions();
         extract($namedExpressions);
         $this->_loadRoutes();
     }
     $params = Router::parse($request->url);
     $request->addParams($params);
     if (!empty($event->data['additionalParams'])) {
         $request->addParams($event->data['additionalParams']);
     }
 }
开发者ID:carriercomm,项目名称:professional-inventory-and-billing-system,代码行数:22,代码来源:Dispatcher.php

示例7: _loadRoutes

 /**
  * Reloads the routes configuration from app/Config/routes.php, and compiles
  * all routes found
  *
  * @return boolean True if config reload was a success, otherwise false
  */
 protected function _loadRoutes()
 {
     Router::reload();
     extract(Router::getNamedExpressions());
     if (!@(include APP . 'Config' . DS . 'routes.php')) {
         return false;
     }
     CakePlugin::routes();
     Router::parse('/');
     foreach (array_keys(Router::getNamedExpressions()) as $var) {
         unset(${$var});
     }
     foreach (Router::$routes as $route) {
         $route->compile();
     }
     return true;
 }
开发者ID:Nervie,项目名称:Beta,代码行数:23,代码来源:ConsoleShell.php

示例8: extract

<?php

/* SVN FILE: $Id$ */
/* Chaw Test cases generated on: 2008-11-18 18:11:32 : 1227060572*/
App::import('Helper', 'Chaw');
App::import('Helper', 'Html');
extract(Router::getNamedExpressions());
include CONFIGS . 'routes.php';
class TestChaw extends ChawHelper
{
}
class ChawHelperTest extends CakeTestCase
{
    function start()
    {
        parent::start();
        $this->Chaw = new TestChaw();
        $this->Chaw->Html = new HtmlHelper();
        $this->Chaw->params = array('url' => array('url' => '/', 'ext' => 'html'));
        $this->Chaw->webroot = '/';
    }
    function testChawInstance()
    {
        $this->assertTrue(is_a($this->Chaw, 'ChawHelper'));
    }
    function testParams()
    {
        $result = $this->Chaw->params(array('id' => 1, 'url' => 'chaw', 'fork' => null));
        $expected = array('project' => null, 'fork' => null);
        $this->assertEqual($result, $expected);
        $result = $this->Chaw->params(array('id' => 2, 'url' => 'some_project', 'fork' => null));
开发者ID:Theaxiom,项目名称:chaw-source,代码行数:31,代码来源:chaw.test.php

示例9: parseParams

 /**
  * Returns array of GET and POST parameters. GET parameters are taken from given URL.
  *
  * @param string $fromUrl URL to mine for parameter information.
  * @return array Parameters found in POST and GET.
  * @access public
  */
 function parseParams($fromUrl)
 {
     $Route = Router::getInstance();
     extract(Router::getNamedExpressions());
     include CONFIGS . 'routes.php';
     $params = Router::parse($fromUrl);
     if (isset($_POST)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             $params['form'] = stripslashes_deep($_POST);
         } else {
             $params['form'] = $_POST;
         }
     }
     if (isset($params['form']['data'])) {
         $params['data'] = Router::stripEscape($params['form']['data']);
         unset($params['form']['data']);
     }
     if (isset($_GET)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             $url = stripslashes_deep($_GET);
         } else {
             $url = $_GET;
         }
         if (isset($params['url'])) {
             $params['url'] = am($params['url'], $url);
         } else {
             $params['url'] = $url;
         }
     }
     foreach ($_FILES as $name => $data) {
         if ($name != 'data') {
             $params['form'][$name] = $data;
         }
     }
     if (isset($_FILES['data'])) {
         foreach ($_FILES['data'] as $key => $data) {
             foreach ($data as $model => $fields) {
                 foreach ($fields as $field => $value) {
                     $params['data'][$model][$field][$key] = $value;
                 }
             }
         }
     }
     $params['bare'] = empty($params['ajax']) ? empty($params['bare']) ? 0 : 1 : 1;
     $params['webservices'] = empty($params['webservices']) ? null : $params['webservices'];
     return $params;
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:54,代码来源:dispatcher.php

示例10: testNamedArgsUrlGeneration

 /**
  * testNamedArgsUrlGeneration method
  *
  * @return void
  */
 public function testNamedArgsUrlGeneration()
 {
     $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 1, 'deleted' => 1));
     $expected = '/posts/index/published:1/deleted:1';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 0, 'deleted' => 0));
     $expected = '/posts/index/published:0/deleted:0';
     $this->assertEquals($expected, $result);
     Router::reload();
     extract(Router::getNamedExpressions());
     Router::connectNamed(array('file' => '[\\w\\.\\-]+\\.(html|png)'));
     Router::connect('/', array('controller' => 'graphs', 'action' => 'index'));
     Router::connect('/:id/*', array('controller' => 'graphs', 'action' => 'view'), array('id' => $ID));
     $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, 'file' => 'asdf.png'));
     $expected = '/12/file:asdf.png';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 12, 'file' => 'asdf.foo'));
     $expected = '/graphs/view/12/file:asdf.foo';
     $this->assertEquals($expected, $result);
     Configure::write('Routing.prefixes', array('admin'));
     Router::reload();
     $request = new CakeRequest();
     Router::setRequestInfo($request->addParams(array('admin' => TRUE, 'controller' => 'controller', 'action' => 'index', 'plugin' => NULL))->addPaths(array('base' => '/', 'here' => '/', 'webroot' => '/base/')));
     Router::parse('/');
     $result = Router::url(array('page' => 1, 0 => NULL, 'sort' => 'controller', 'direction' => 'asc', 'order' => NULL));
     $expected = "/admin/controller/index/page:1/sort:controller/direction:asc";
     $this->assertEquals($expected, $result);
     Router::reload();
     $request = new CakeRequest('admin/controller/index');
     $request->addParams(array('admin' => TRUE, 'controller' => 'controller', 'action' => 'index', 'plugin' => NULL));
     $request->base = '/';
     Router::setRequestInfo($request);
     Router::parse('/admin/controller/index/type:whatever');
     $result = Router::url(array('type' => 'new'));
     $expected = "/admin/controller/index/type:new";
     $this->assertEquals($expected, $result);
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:42,代码来源:RouterTest.php


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