當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Router::parseExtensions方法代碼示例

本文整理匯總了PHP中Cake\Routing\Router::parseExtensions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Router::parseExtensions方法的具體用法?PHP Router::parseExtensions怎麽用?PHP Router::parseExtensions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\Routing\Router的用法示例。


在下文中一共展示了Router::parseExtensions方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testReverseWithExtension

 /**
  * Test that extensions work with Router::reverse()
  *
  * @return void
  */
 public function testReverseWithExtension()
 {
     Router::connect('/:controller/:action/*');
     Router::parseExtensions('json', false);
     $request = new Request('/posts/view/1.json');
     $request->addParams(array('controller' => 'posts', 'action' => 'view', 'pass' => array(1), 'ext' => 'json'));
     $request->query = [];
     $result = Router::reverse($request);
     $expected = '/posts/view/1.json';
     $this->assertEquals($expected, $result);
 }
開發者ID:ripzappa0924,項目名稱:carte0.0.1,代碼行數:16,代碼來源:RouterTest.php

示例2: testNoViewClassExtension

 /**
  * test configured extension but no view class set.
  */
 public function testNoViewClassExtension()
 {
     Router::parseExtensions(['json', 'xml', 'ajax', 'csv'], false);
     $this->Controller->request->params['_ext'] = 'csv';
     $event = new Event('Controller.startup', $this->Controller);
     $this->RequestHandler->initialize($event);
     $this->RequestHandler->startup($event);
     $this->assertEquals('RequestHandlerTest/csv', $this->Controller->viewPath);
     $this->assertEquals('csv', $this->Controller->layoutPath);
 }
開發者ID:ripzappa0924,項目名稱:carte0.0.1,代碼行數:13,代碼來源:RequestHandlerComponentTest.php

示例3:

 * 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
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace App\Config;

use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Routing\Router;
Router::parseExtensions('json', 'xml');
/**
 * Uncomment the define below to use CakePHP prefix routes.
 *
 * The value of the define determines the names of the routes
 * and their associated controller actions:
 *
 * Set to an array of prefixes you want to use in your application. Use for
 * admin or other prefixed routes.
 *
 * Routing.prefixes = array('admin', 'manager');
 *
 * Enables:
 *  `App\Controller\Admin` and `/admin/controller/index`
 *  `App\Controller\Manager` and `/manager/controller/index`
 *
開發者ID:vpolpeta,項目名稱:crud-demo-app,代碼行數:31,代碼來源:routes.php

示例4: array

<?php

/**
 * Routes file
 *
 * Routes for test app
 *
 * CakePHP : 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 Project
 * @since         2.0.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace TestApp\Config;

use Cake\Routing\Router;
// Configure::write('Routing.prefixes', array());
Router::parseExtensions('json');
Router::connect('/some_alias', array('controller' => 'tests_apps', 'action' => 'some_method'));
Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']);
require CAKE . 'Config/routes.php';
開發者ID:ripzappa0924,項目名稱:carte0.0.1,代碼行數:27,代碼來源:routes.php


注:本文中的Cake\Routing\Router::parseExtensions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。