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


PHP Router::extensions方法代码示例

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


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

示例1: __construct

 /**
  * __construct
  *
  * @param CakeRequest $request
  * @param CakeResponse $response
  */
 public function __construct($request = null, $response = null)
 {
     parent::__construct($request, $response);
     if (count(Router::extensions())) {
         $this->components[] = 'RequestHandler';
     }
     $this->constructClasses();
     $this->Components->trigger('initialize', array(&$this));
     $this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
     if (isset($this->RequestHandler)) {
         $this->RequestHandler->startup($this);
     }
 }
开发者ID:ndreynolds,项目名称:arcs,代码行数:19,代码来源:CakeErrorController.php

示例2: __construct

 /**
  * __construct
  *
  * @param CakeRequest $request
  * @param CakeResponse $response
  */
 public function __construct($request = null, $response = null)
 {
     parent::__construct($request, $response);
     $this->constructClasses();
     if (count(Router::extensions()) && !$this->Components->attached('RequestHandler')) {
         $this->RequestHandler = $this->Components->load('RequestHandler');
     }
     if ($this->Components->enabled('Auth')) {
         $this->Components->disable('Auth');
     }
     if ($this->Components->enabled('Security')) {
         $this->Components->disable('Security');
     }
     $this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
 }
开发者ID:slachiewicz,项目名称:_mojePanstwo-API-Server,代码行数:21,代码来源:CakeErrorController.php

示例3: __construct

 /**
  * __construct
  *
  * @param CakeRequest $request
  * @param CakeResponse $response
  */
 public function __construct($request = null, $response = null)
 {
     parent::__construct($request, $response);
     if (count(Router::extensions()) && !array_key_exists('RequestHandler', $this->components) && !in_array('RequestHandler', $this->components, true)) {
         $this->components[] = 'RequestHandler';
     }
     $this->constructClasses();
     if ($this->Components->enabled('Auth')) {
         $this->Components->disable('Auth');
     }
     if ($this->Components->enabled('Security')) {
         $this->Components->disable('Security');
     }
     $this->startupProcess();
     $this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
 }
开发者ID:safikul,项目名称:cakephp,代码行数:22,代码来源:CakeErrorController.php

示例4: __construct

 /**
  * __construct
  *
  * @param CakeRequest $request
  * @param CakeResponse $response
  */
 public function __construct(CakeRequest $request, CakeResponse $response)
 {
     parent::__construct($request, $response);
     if (count(Router::extensions())) {
         $this->components[] = 'RequestHandler';
     }
     try {
         $this->constructClasses();
         $this->startupProcess();
     } catch (CakeException $e) {
         CakeLog::write('critical', __d('croogo', 'Errors in CakeErrorController: %s', $e->getMessage()));
     }
     $this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
     if (isset($this->RequestHandler)) {
         $this->RequestHandler->startup($this);
     }
 }
开发者ID:ahmadhasankhan,项目名称:croogo,代码行数:23,代码来源:CroogoErrorController.php

示例5: __construct

 public function __construct($request = null, $response = null)
 {
     parent::__construct($request, $response);
     $this->_mergeControllerVars();
     unset($this->components['Acl']);
     unset($this->components['Auth']);
     $this->Components->init($this);
     if ($this->uses) {
         $this->uses = (array) $this->uses;
         list(, $this->modelClass) = pluginSplit(current($this->uses));
     }
     if (count(Router::extensions()) && !$this->Components->attached('RequestHandler')) {
         $this->RequestHandler = $this->Components->load('RequestHandler');
     }
     if ($this->Components->enabled('Auth')) {
         $this->Components->disable('Auth');
     }
     if ($this->Components->enabled('Security')) {
         $this->Components->disable('Security');
     }
     $this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:22,代码来源:AppErrorController.php

示例6: testExtensionParsingSetting

 /**
  * testExtensionParsingSetting method
  *
  * @return void
  */
 public function testExtensionParsingSetting()
 {
     $this->assertEquals(array(), Router::extensions());
     Router::parseExtensions('rss');
     $this->assertEquals(Router::extensions(), array('rss'));
 }
开发者ID:nabeelio,项目名称:CakePHP-Base,代码行数:11,代码来源:RouterTest.php

示例7: testInitializeContentTypeAndExtensionMismatch

 /**
  * Test that a type mismatch doesn't incorrectly set the ext
  *
  * @return void
  */
 public function testInitializeContentTypeAndExtensionMismatch()
 {
     $this->assertNull($this->RequestHandler->ext);
     $extensions = Router::extensions();
     Router::parseExtensions('xml');
     $this->Controller->request = $this->getMock('CakeRequest');
     $this->Controller->request->expects($this->any())->method('accepts')->will($this->returnValue(array('application/json')));
     $this->RequestHandler->initialize($this->Controller);
     $this->assertNull($this->RequestHandler->ext);
     call_user_func_array(array('Router', 'parseExtensions'), $extensions);
 }
开发者ID:saihe,项目名称:reservation,代码行数:16,代码来源:RequestHandlerComponentTest.php

示例8: _setExtension

 /**
  * Set the extension based on the accept headers.
  * Compares the accepted types and configured extensions.
  * If there is one common type, that is assigned as the ext/content type
  * for the response.
  *
  * If html is one of the preferred types, no content type will be set, this
  * is to avoid issues with browsers that prefer html and several other content types.
  *
  * @return void
  */
 protected function _setExtension()
 {
     $accept = $this->request->parseAccept();
     if (empty($accept)) {
         return;
     }
     $extensions = Router::extensions();
     $preferred = array_shift($accept);
     $preferredTypes = $this->response->mapType($preferred);
     if (!in_array('xhtml', $preferredTypes) && !in_array('html', $preferredTypes)) {
         $similarTypes = array_intersect($extensions, $preferredTypes);
         if (count($similarTypes) === 1) {
             $this->ext = array_shift($similarTypes);
         }
     }
 }
开发者ID:rednazj,项目名称:Inventory,代码行数:27,代码来源:RequestHandlerComponent.php

示例9: 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

示例10: _setExtension

 /**
  * Set the extension based on the accept headers.
  * Compares the accepted types and configured extensions.
  * If there is one common type, that is assigned as the ext/content type
  * for the response.
  * Type with the highest weight will be set. If the highest weight has more
  * then one type matching the extensions, the order in which extensions are specified
  * determines which type will be set.
  *
  * If html is one of the preferred types, no content type will be set, this
  * is to avoid issues with browsers that prefer html and several other content types.
  *
  * @return void
  */
 protected function _setExtension()
 {
     $accept = $this->request->parseAccept();
     if (empty($accept)) {
         return;
     }
     $accepts = $this->response->mapType($this->request->parseAccept());
     $preferedTypes = current($accepts);
     if (array_intersect($preferedTypes, array('html', 'xhtml'))) {
         return null;
     }
     $extensions = Router::extensions();
     foreach ($accepts as $types) {
         $ext = array_intersect($extensions, $types);
         if ($ext) {
             $this->ext = current($ext);
             break;
         }
     }
 }
开发者ID:jgera,项目名称:orangescrum,代码行数:34,代码来源:RequestHandlerComponent.php

示例11: array

<?php

Router::connect('/admin', array('controller' => 'Welcome', 'action' => 'index', 'admin' => true, 'plugin' => 'trois'));
Router::connect('/sitemap', array('controller' => 'Sitemap', 'action' => 'index', 'admin' => false, 'plugin' => 'trois'));
$extentions = Router::extensions();
if (empty($extentions)) {
    Router::parseExtensions('json', 'xml');
} else {
    if (array_search('json', $extentions) === false) {
        array_push($extentions, 'json');
    }
    if (array_search('xml', $extentions) === false) {
        array_push($extentions, 'xml');
    }
    call_user_func_array('Router::parseExtensions', $extentions);
}
开发者ID:awallef,项目名称:trois,代码行数:16,代码来源:routes.php

示例12: initialize

 /**
  * Initializes the component, gets a reference to Controller::$parameters, and
  * checks to see if a file extension has been parsed by the Router.  Or if the 
  * HTTP_ACCEPT_TYPE is set to a single value that is a supported extension and mapped type.
  * If yes, RequestHandler::$ext is set to that value
  *
  * @param object $controller A reference to the controller
  * @param array $settings Array of settings to _set().
  * @return void
  * @see Router::parseExtensions()
  */
 public function initialize($controller, $settings = array())
 {
     $this->request = $controller->request;
     $this->response = $controller->response;
     if (isset($this->request->params['url']['ext'])) {
         $this->ext = $this->request->params['url']['ext'];
     }
     if (empty($this->ext)) {
         $accepts = $this->request->accepts();
         $extensions = Router::extensions();
         if (count($accepts) == 1) {
             $mapped = $this->mapType($accepts[0]);
             if (in_array($mapped, $extensions)) {
                 $this->ext = $mapped;
             }
         }
     }
     $this->params = $controller->params;
     $this->_set($settings);
 }
开发者ID:robotarmy,项目名称:Phog,代码行数:31,代码来源:request_handler.php


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