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


PHP Zend_Controller_Router_Route::assemble方法代码示例

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


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

示例1: assemble

 public function assemble($data = array(), $reset = false, $encode = false)
 {
     $return = parent::assemble($data, $reset, $encode);
     if ($this->_representationParam !== null) {
         if ($return && isset($data[$this->_representationParam])) {
             $return .= '.' . $data[$this->_representationParam];
         }
     }
     return $return;
 }
开发者ID:sitengine,项目名称:sitengine,代码行数:10,代码来源:Route.php

示例2: assemble

 /**
  * Assembles user submitted parameters forming a URL path defined by this route
  *
  * @param  array $ An array of variable and value pairs used as parameters
  * @param  boolean $reset Whether or not to set route defaults with those provided in $data
  * @return string Route path with user submitted parameters
  */
 public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
 {
     // TODO: We should take the paramValues/mvcParams into account shouldn't we? For now
     // This router doesn't support full reverse assembly I guess.
     return parent::assemble($data, $reset, $encode, $partial);
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:13,代码来源:RequestVars.php

示例3: testEscapedSpecialCharsWithTranslation

 public function testEscapedSpecialCharsWithTranslation()
 {
     $route = new Zend_Controller_Router_Route('::foo/@@bar/:@myvar');
     $path = $route->assemble(array('myvar' => 'foo'));
     $this->assertEquals($path, ':foo/@bar/en_foo');
     $values = $route->match(':foo/@bar/en_foo');
     $this->assertEquals($values['myvar'], 'foo');
 }
开发者ID:netvlies,项目名称:zf,代码行数:8,代码来源:RouteTest.php

示例4: testAssembleWithRemovedDefaults

    public function testAssembleWithRemovedDefaults() // Test for ZF-1197
    {    
        $route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index'));
        
        $url = $route->assemble(array('id' => 3));
        $this->assertSame('index/index/id/3', $url);

        $url = $route->assemble(array('action' => 'test'));
        $this->assertSame('index/test', $url);

        $url = $route->assemble(array('action' => 'test', 'id' => 3));
        $this->assertSame('index/test/id/3', $url);

        $url = $route->assemble(array('controller' => 'test'));
        $this->assertSame('test', $url);

        $url = $route->assemble(array('controller' => 'test', 'action' => 'test'));
        $this->assertSame('test/test', $url);

        $url = $route->assemble(array('controller' => 'test', 'id' => 3));
        $this->assertSame('test/index/id/3', $url);

        $url = $route->assemble(array());
        $this->assertSame('', $url);

        $route->match('ctrl');

        $url = $route->assemble(array('id' => 3));
        $this->assertSame('ctrl/index/id/3', $url);

        $url = $route->assemble(array('action' => 'test'));
        $this->assertSame('ctrl/test', $url);

        $url = $route->assemble();
        $this->assertSame('ctrl', $url);
        
        $route->match('index');
        
        $url = $route->assemble();
        $this->assertSame('', $url);
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:41,代码来源:RouteTest.php

示例5: assemble

 /**
  * Assembles user submitted parameters forming a URL path defined by this route
  *
  * We cannot generate http://subdomain.domain.com/ due to the fact
  * that the url helper adds the baseUrl in front of it... *sigh*
  * 
  * @todo figure out a workaround
  * 
  * @param  array $data An array of variable and value pairs used as parameters
  * @param  boolean $reset Whether or not to set route defaults with those provided in $data
  * @return string Route path with user submitted parameters
  */
 public function assemble($data = array(), $reset = false)
 {
     return parent::assemble($data, $reset);
 }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:16,代码来源:HttpHost.php

示例6: testAssembleWithVariableMissing

 public function testAssembleWithVariableMissing()
 {
     $route = new Zend_Controller_Router_Route('archive/:year', array('controller' => 'archive', 'action' => 'show'), array('year' => '\\d+'));
     try {
         $url = $route->assemble();
     } catch (Exception $e) {
     }
     $this->assertTrue($e instanceof Zend_Controller_Router_Exception, 'Expected Zend_Controller_Router_Exception to be thrown');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:RouteTest.php

示例7: testAssembleWithUrlVariablesReuse

 public function testAssembleWithUrlVariablesReuse()
 {
     $route = new Zend_Controller_Router_Route('archives/:year/:month');
     $values = $route->match('archives/2006/07');
     $this->assertType('array', $values);
     $url = $route->assemble(array('month' => '03'));
     $this->assertSame('archives/2006/03', $url);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:8,代码来源:RouteTest.php

示例8: testAssembleWithDefaultAndValue

 public function testAssembleWithDefaultAndValue()
 {
     $route = new Zend_Controller_Router_Route('authors/:name', array('name' => 'martel'));
     $url = $route->assemble(array('name' => 'mike'));
     $this->assertEquals('authors/mike', $url);
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:6,代码来源:RouteTest.php

示例9: assemble

 /**
  * Assembles user submitted parameters forming a URL path defined by this route
  *
  * @param  array $data An array of variable and value pairs used as parameters
  * @param  boolean $reset Whether or not to set route defaults with those provided in $data
  * @return string Route path with user submitted parameters
  */
 public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
 {
     if (!isset($data['locale'])) {
         return parent::assemble($data, $reset, $encode, $partial);
     }
     $locale = $data['locale'];
     unset($data['locale']);
     $assemble = parent::assemble($data, $reset, $encode);
     if (in_array($locale, self::$_locales)) {
         if (isset($this->_defaults['locale'])) {
             $defaultLocale = $this->_defaults['locale'];
         } else {
             $defaultLocale = self::$_defaultLocale;
         }
         if ($locale != $defaultLocale) {
             $assemble = implode($this->_urlDelimiter, array($locale, $assemble));
         }
     }
     return $assemble;
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:27,代码来源:Front.php

示例10: testEncode

    public function testEncode()
    {
        $route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index'));
        
        $url = $route->assemble(array('controller' => 'My Controller'), false, true);
        $this->assertEquals('My+Controller', $url);

        $url = $route->assemble(array('controller' => 'My Controller'), false, false);
        $this->assertEquals('My Controller', $url);

        $token = $route->match('en/foo/id/My Value');
    
        $url = $route->assemble(array(), false, true);
        $this->assertEquals('en/foo/id/My+Value', $url);
        
        $url = $route->assemble(array('id' => 'My Other Value'), false, true);
        $this->assertEquals('en/foo/id/My+Other+Value', $url);
        
        $route = new Zend_Controller_Router_Route(':controller/*', array('controller' => 'My Controller'));
        $url = $route->assemble(array('id' => 1), false, true);
        $this->assertEquals('My+Controller/id/1', $url);
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:22,代码来源:RouteTest.php

示例11: testAssembleResetDefaults

 public function testAssembleResetDefaults()
 {
     $route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index'));
     $values = $route->match('news/view/id/3');
     $url = $route->assemble(array('action' => null));
     $this->assertSame('news/index/id/3', $url);
     $url = $route->assemble(array('action' => null, 'id' => null));
     $this->assertSame('news/index', $url);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:RouteTest.php

示例12: assemble

 /**
  * Assembles user submitted parameters forming a URL path defined by this route
  *
  * @param  array $data An array of variable and value pairs used as parameters
  * @param  boolean $reset Whether or not to set route defaults with those provided in $data
  * @return string Route path with user submitted parameters
  */
 public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
 {
     $locale = null;
     if (!empty($data['locale'])) {
         // This locale is always valid. It's a developer filtered input
         $locale = trim($data['locale'], '/ ');
     } else {
         $locale = trim(Axis_Locale::getLanguageUrl(), '/ ');
     }
     unset($data['locale']);
     $assemble = parent::assemble($data, $reset, $encode, $partial);
     if (empty($locale)) {
         return $assemble;
     }
     $isValidLocale = false;
     foreach (self::$_locales as $_locale) {
         if (strpos($_locale, $locale) === 0) {
             $isValidLocale = true;
             break;
         }
     }
     if ($isValidLocale) {
         if (isset($this->_defaults['locale'])) {
             $defaultLocale = $this->_defaults['locale'];
         } else {
             $defaultLocale = self::$_defaultLocale;
         }
         if ($locale != $defaultLocale) {
             if (empty($assemble)) {
                 // preventing urlDelimiter at the end of the url for the homepage
                 $assemble = $locale;
             } else {
                 $assemble = implode($this->_urlDelimiter, array($locale, $assemble));
             }
         }
     }
     return $assemble;
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:45,代码来源:Front.php

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