本文整理汇总了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);
}
示例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);
}
示例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`
*
示例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';