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


PHP Zend_Controller_Router_Route::getDefaults方法代码示例

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


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

示例1: testGetDefaults

 public function testGetDefaults()
 {
     $route = new Zend_Controller_Router_Route('users/all', array('controller' => 'ctrl', 'action' => 'act'));
     $values = $route->getDefaults();
     $this->assertType('array', $values);
     $this->assertEquals('ctrl', $values['controller']);
     $this->assertEquals('act', $values['action']);
 }
开发者ID:netvlies,项目名称:zf,代码行数:8,代码来源:RouteTest.php

示例2: _buildQuery

 /**
  * Builds the query part of the URL
  */
 protected function _buildQuery()
 {
     $event = new Erfurt_Event('onBuildUrl');
     $event->base = $this->_base;
     $event->route = $this->_route;
     $event->controller = $this->_controller;
     $event->action = $this->_action;
     $event->params = $this->_params;
     $urlCreated = $event->trigger();
     if ($event->handled()) {
         if ($urlCreated && isset($event->url)) {
             return $event->url;
         } else {
             $this->_params = $event->params;
             $this->_controller = $event->controller;
             $this->_action = $event->action;
             $this->_route = $event->route;
         }
     }
     // check params
     foreach ($this->_params as $name => $value) {
         if (is_string($value) && preg_match('/\\//', $value)) {
             $this->_useSefUrls = false;
         }
     }
     $url = '';
     if ($this->_route) {
         // checking if reset of route-defaults necessary
         // fixes pager usage fails on versioning pages
         if (count($this->_route->getDefaults()) == 0) {
             $resetRoute = false;
         } else {
             $resetRoute = true;
         }
         if ($this->_useSefUrls) {
             // let the route assemble the whole URL
             $url = $this->_route->assemble($this->_params, $resetRoute, true);
         } else {
             // we will assign parameters ourselves
             $url = $this->_route->assemble(array(), $resetRoute);
             $url = sprintf('%s/%s', $url, '?' . http_build_query($this->_params, '&'));
         }
     } else {
         if ($this->_useSefUrls) {
             $query = '';
             $lastKey = '';
             foreach ($this->_params as $key => $value) {
                 if (is_scalar($value)) {
                     $value = urlencode($value);
                     $query .= "{$key}/{$value}/";
                     $lastKey = $key;
                 }
             }
             // remove trailing slash
             $query = rtrim($query, '/');
         } else {
             $query = '?' . http_build_query($this->_params, '&');
         }
         $parts = array_filter(array($this->_controller, $this->_action, $query));
         $url = implode('/', $parts);
     }
     // HACK:
     $this->_useSefUrls = true;
     return $this->_base . ltrim($url, '/');
 }
开发者ID:dmj,项目名称:uni-helmstedt.hab.de,代码行数:68,代码来源:Url.php


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