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


PHP Router::setExtensions方法代码示例

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


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

示例1: testInitializeNoContentTypeWithMultipleAcceptedTypes

 /**
  * Test that ext is set to the first listed extension with multiple accepted
  * content types.
  * Having multiple types accepted with same weight, means the client lets the
  * server choose the returned content type.
  *
  * @return void
  */
 public function testInitializeNoContentTypeWithMultipleAcceptedTypes()
 {
     $_SERVER['HTTP_ACCEPT'] = 'application/json, application/javascript, application/xml, */*; q=0.01';
     $this->assertNull($this->RequestHandler->ext);
     Router::parseExtensions('xml', 'json');
     $this->RequestHandler->initialize($this->Controller);
     $this->assertEquals('xml', $this->RequestHandler->ext);
     $this->RequestHandler->ext = null;
     Router::setExtensions(array('json', 'xml'), false);
     $this->RequestHandler->initialize($this->Controller);
     $this->assertEquals('json', $this->RequestHandler->ext);
 }
开发者ID:saihe,项目名称:reservation,代码行数:20,代码来源:RequestHandlerComponentTest.php

示例2: array

 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Config
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
Router::parseExtensions();
Router::setExtensions(array('json'));
Router::connect('/', array('controller' => 'boards', 'action' => 'all'));
Router::connect('/login', array('controller' => 'sessions', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'sessions', 'action' => 'logout'));
Router::connect('/dashboard', array('controller' => 'users', 'action' => 'dashboard'));
Router::connect('/teams', array('controller' => 'users', 'action' => 'random_teams'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
if (AuthComponent::user()) {
    // authenticated routes
} else {
    // unauthenticated routes
}
CakePlugin::routes();
require CAKE . 'Config' . DS . 'routes.php';
开发者ID:taolander,项目名称:zap-pong,代码行数:31,代码来源:routes.php

示例3: testSetExtensions

 /**
  * testSetExtensions method
  *
  * @return void
  */
 public function testSetExtensions()
 {
     Router::setExtensions(array('rss'));
     $this->assertEquals(array('rss'), Router::extensions());
     require CAKE . 'Config' . DS . 'routes.php';
     $result = Router::parse('/posts.rss');
     $this->assertFalse(isset($result['ext']));
     Router::parseExtensions();
     $result = Router::parse('/posts.rss');
     $this->assertEquals('rss', $result['ext']);
     $result = Router::parse('/posts.xml');
     $this->assertFalse(isset($result['ext']));
     Router::setExtensions(array('xml'));
     $result = Router::extensions();
     $this->assertEquals(array('rss', 'xml'), $result);
     $result = Router::parse('/posts.xml');
     $this->assertEquals('xml', $result['ext']);
     $result = Router::setExtensions(array('pdf'), false);
     $this->assertEquals(array('pdf'), $result);
 }
开发者ID:keetamhoang,项目名称:lotdephong,代码行数:25,代码来源:RouterTest.php

示例4:

<?php

/**
 * Note: Router::setExtensions() is available since CakePHP 2.2
 * If you use 2.1 dont load this routes file, and add xls and xlsx to your parseExtensions() in app/Config/routes.php
 */
Router::parseExtensions();
Router::setExtensions(array('xls', 'xlsx'));
开发者ID:edukondaluetg,项目名称:CakeExcel,代码行数:8,代码来源:routes.php

示例5: array

<?php

/**
 * Route's defaults.
 *
 * @var array
 */
$defaults = array('plugin' => 'webmaster', 'controller' => 'webmaster');
/**
 * Force usage of the CakeRoute class to avoid duplicates that are useless anyways
 * (i.e. /fr/sitemap.xml, /sp/robots.txt).
 *
 * @var array
 */
$options = array('routeClass' => 'CakeRoute');
/**
 * Add the `txt` and `xml` extensions.
 */
Router::setExtensions(array('txt', 'xml'));
/**
 * Route `/robots.txt`.
 */
Router::connect('/robots', array_merge($defaults, array('action' => 'robots', 'ext' => 'txt')), $options);
Router::promote();
/**
 * Route `/sitemap.xml`.
 */
Router::connect('/sitemap', array_merge($defaults, array('action' => 'sitemap', 'ext' => 'xml')), $options);
Router::promote();
unset($options, $defaults);
开发者ID:gourmet,项目名称:webmaster,代码行数:30,代码来源:routes.php

示例6: array

<?php

Router::parseExtensions();
Router::setExtensions(array('json', 'xml', 'csv', 'rss', 'pdf'));
Router::connect('/', array('controller' => 'overview', 'action' => 'index'));
Router::connect('/register', array('controller' => 'account', 'action' => 'register'));
Router::connect('/login', array('controller' => 'account', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'account', 'action' => 'logout'));
//route to switch locale
//Router::connect('/lang/*', array('controller' => 'p28n', 'action' => 'change'));
Router::connect('/admin', array('admin' => 'admin', 'controller' => 'overview', 'action' => 'index'));
//Router::connect('/translate', array('plugin' => 'translate', 'controller' => 'translate_groups', 'action' => 'overview'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
CakePlugin::routes();
/**
 * Load the CakePHP default routes. Only remove this if you do not want to use
 * the built-in default routes.
 */
require CAKE . 'Config' . DS . 'routes.php';
开发者ID:dereuromark,项目名称:cakephp-sandbox,代码行数:19,代码来源:routes.php

示例7: array

 * @package       app.Config
 * @since         CakePHP(tm) v 0.2.9
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/View/Pages/home.ctp)...
 */
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
 * ...and connect the rest of 'Pages' controller's URLs.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
 * Load all plugin routes. See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
CakePlugin::routes();
/**
 * Load all plugin routes. See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
CakePlugin::routes();
Router::setExtensions(array('json'), true);
Router::parseExtensions('json');
/**
 * Load the CakePHP default routes. Only remove this if you do not want to use
 * the built-in default routes.
 */
require CAKE . 'Config' . DS . 'routes.php';
开发者ID:vijaychirivolu,项目名称:aW5zdGl0dXRlcyajiv,代码行数:31,代码来源:routes.php

示例8:

<?php

/**
 * Note: Router::setExtensions() is available since CakePHP 2.2
 * If you use 2.1 dont load this routes file, and add pdf to your parseExtensions() in app/Config/routes.php
 */
Router::parseExtensions();
Router::setExtensions(array('pdf'));
开发者ID:kuwox,项目名称:buenavista,代码行数:8,代码来源:routes.php


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