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


PHP Router::extensions方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param \Cake\Network\Request $request Request instance.
  * @param \Cake\Network\Response $response Reponse instance.
  */
 public function __construct($request = null, $response = null)
 {
     parent::__construct($request, $response);
     if (count(Router::extensions()) && !isset($this->RequestHandler)) {
         $this->loadComponent('RequestHandler');
     }
     $eventManager = $this->eventManager();
     if (isset($this->Auth)) {
         $eventManager->detach($this->Auth);
     }
     if (isset($this->Security)) {
         $eventManager->detach($this->Security);
     }
     $this->cacheAction = false;
     $this->viewPath = 'Error';
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:22,代码来源:ErrorController.php

示例2: setUp

 /**
  * [setUp description]
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->resetReflectionCache();
     $this->_eventManager = EventManager::instance();
     $existing = Configure::read('App.paths.templates');
     $existing[] = Plugin::path('Crud') . 'tests/App/Template/';
     Configure::write('App.paths.templates', $existing);
     Configure::write('App.namespace', 'Crud\\Test\\App');
     Router::extensions('json');
     Router::connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);
     Router::connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);
     $this->useHttpServer(false);
 }
开发者ID:friendsofcake,项目名称:crud,代码行数:19,代码来源:IntegrationTestCase.php

示例3: __construct

 /**
  * Constructor
  *
  * @param \Cake\Network\Request|null $request Request instance.
  * @param \Cake\Network\Response|null $response Response instance.
  */
 public function __construct($request = null, $response = null)
 {
     parent::__construct($request, $response);
     if (count(Router::extensions()) && !isset($this->RequestHandler)) {
         $this->loadComponent('RequestHandler');
     }
     $eventManager = $this->eventManager();
     if (isset($this->Auth)) {
         $eventManager->off($this->Auth);
     }
     if (isset($this->Security)) {
         $eventManager->off($this->Security);
     }
 }
开发者ID:CakeDC,项目名称:cakephp,代码行数:20,代码来源:ErrorController.php

示例4: testReverseWithExtension

 /**
  * Test that extensions work with Router::reverse()
  *
  * @return void
  */
 public function testReverseWithExtension()
 {
     Router::connect('/:controller/:action/*');
     Router::extensions('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:maitrepylos,项目名称:nazeweb,代码行数:16,代码来源:RouterTest.php

示例5: testSetExtensions

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

示例6:

     * Connect catchall routes for all controllers.
     *
     * Using the argument `DashedRoute`, the `fallbacks` method is a shortcut for
     *    `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);`
     *    `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);`
     *
     * Any route class can be used with this method, such as:
     * - DashedRoute
     * - InflectedRoute
     * - Route
     * - Or your own route class
     *
     * You can remove these routes once you've connected the
     * routes you want in your application.
     */
    //$routes->fallbacks('DashedRoute');
    /**    
     * map controller resources
     */
    Router::mapResources('users');
    Router::mapResources('books');
    Router::mapResources('authors');
    Router::mapResources('BookIssues');
    Router::mapResources('geners');
    Router::extensions(['json', 'xml']);
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();
开发者ID:BharadhwajGummadi,项目名称:library,代码行数:31,代码来源:routes.php

示例7: function

 * to set as the default:
 *
 * - Route
 * - InflectedRoute
 * - DashedRoute
 *
 * If no call is made to `Router::defaultRouteClass`, the class used is
 * `Route` (`Cake\Routing\Route\Route`)
 *
 * Note that `Route` does not do any inflections on URLs which will result in
 * inconsistently cased URLs when used with `:plugin`, `:controller` and
 * `:action` markers.
 *
 */
Router::defaultRouteClass('Route');
Router::extensions('json');
Router::scope('/', function ($routes) {
    /**
     * Here, we are connecting '/' (base path) to a controller called 'Pages',
     * its action called 'display', and we pass a param to select the view file
     * to use (in this case, src/Template/Pages/home.ctp)...
     */
    $routes->connect('/', ['controller' => 'Prognostics', 'action' => 'home']);
    /**
     * ...and connect the rest of 'Pages' controller's URLs.
     */
    $routes->connect('/*', ['controller' => 'Pages', 'action' => 'page404']);
    $routes->connect('/prognostic/:id', ['controller' => 'Prognostics', 'action' => 'pronostic'], ['id' => '\\d+', 'pass' => ['id']]);
    $routes->connect('/ticket/:id/:match', ['controller' => 'Prognostics', 'action' => 'ticket'], ['id' => '\\d+', 'match' => '\\w+', 'pass' => ['id', 'match']]);
    $routes->connect('/cgu', ['controller' => 'Pages', 'action' => 'cgu']);
    $routes->connect('/login', ['controller' => 'Users', 'action' => 'login']);
开发者ID:laurentdamien,项目名称:sportlay,代码行数:31,代码来源:routes.php

示例8: testNoViewClassExtension

 /**
  * test configured extension but no view class set.
  *
  * @return void
  * @triggers Controller.beforeRender $this->Controller
  */
 public function testNoViewClassExtension()
 {
     Router::extensions(['json', 'xml', 'ajax', 'csv'], false);
     $this->Controller->request->params['_ext'] = 'csv';
     $event = new Event('Controller.startup', $this->Controller);
     $this->RequestHandler->initialize([]);
     $this->RequestHandler->startup($event);
     $this->Controller->eventManager()->on('Controller.beforeRender', function () {
         return $this->Controller->response;
     });
     $this->Controller->render();
     $this->assertEquals('RequestHandlerTest' . DS . 'csv', $this->Controller->viewBuilder()->templatePath());
     $this->assertEquals('csv', $this->Controller->viewBuilder()->layoutPath());
 }
开发者ID:Slayug,项目名称:castor,代码行数:20,代码来源:RequestHandlerComponentTest.php

示例9: testScopeExtensionsContained

 /**
  * Test to ensure that extensions defined in scopes don't leak.
  * And that global extensions are propagated.
  *
  * @return void
  */
 public function testScopeExtensionsContained()
 {
     Router::extensions(['json']);
     Router::scope('/', function ($routes) {
         $this->assertEquals(['json'], $routes->extensions(), 'Should default to global extensions.');
         $routes->extensions(['rss']);
         $this->assertEquals(['rss'], $routes->extensions(), 'Should include new extensions.');
         $routes->connect('/home', []);
     });
     $this->assertEquals(['json', 'rss'], array_values(Router::extensions()));
     Router::scope('/api', function ($routes) {
         $this->assertEquals(['json'], $routes->extensions(), 'Should default to global extensions.');
         $routes->extensions(['json', 'csv']);
         $routes->connect('/export', []);
         $routes->scope('/v1', function ($routes) {
             $this->assertEquals(['json', 'csv'], $routes->extensions());
         });
     });
     $this->assertEquals(['json', 'rss', 'csv'], array_values(Router::extensions()));
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:26,代码来源:RouterTest.php

示例10: function

 * to set as the default:
 *
 * - Route
 * - InflectedRoute
 * - DashedRoute
 *
 * If no call is made to `Router::defaultRouteClass`, the class used is
 * `Route` (`Cake\Routing\Route\Route`)
 *
 * Note that `Route` does not do any inflections on URLs which will result in
 * inconsistently cased URLs when used with `:plugin`, `:controller` and
 * `:action` markers.
 *
 */
Router::defaultRouteClass('Route');
Router::extensions(['csv', 'json', 'html']);
Router::scope('/', function ($routes) {
    /**
     * Here, we are connecting '/' (base path) to a controller called 'Pages',
     * its action called 'display', and we pass a param to select the view file
     * to use (in this case, src/Template/Pages/home.ctp)...
     */
    $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
    //Just as an example. Might not bother keeping custom routes like this:
    $routes->connect('/create', ['controller' => 'Clubs', 'action' => 'create']);
    /**
     * ...and connect the rest of 'Pages' controller's URLs.
     */
    $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
    /**
     * Catching urls based on old system. Can delete later
开发者ID:byu-oit-appdev,项目名称:byusa-clubs,代码行数:31,代码来源:routes.php

示例11: function

<?php

use Cake\Routing\Router;
Router::extensions(['html', 'json']);
Router::plugin('BoxManager', ['path' => '/box-manager'], function ($routes) {
    $routes->connect('/login', ['controller' => 'Users', 'action' => 'login']);
    $routes->fallbacks('DashedRoute');
});
Router::prefix('admin', function ($routes) {
    $routes->plugin('BoxManager', ['path' => '/box-manager'], function ($routes) {
        $routes->fallbacks('DashedRoute');
    });
    $routes->fallbacks('DashedRoute');
});
开发者ID:Aerue,项目名称:avalia,代码行数:14,代码来源:routes.php

示例12: testInitializeContentTypeAndExtensionMismatch

 /**
  * Test that a type mismatch doesn't incorrectly set the ext
  *
  * @return void
  */
 public function testInitializeContentTypeAndExtensionMismatch()
 {
     $event = new Event('Controller.initialize', $this->Controller);
     $this->assertNull($this->RequestHandler->ext);
     $extensions = Router::extensions();
     Router::parseExtensions('xml', false);
     $this->Controller->request = $this->getMock('Cake\\Network\\Request', ['accepts']);
     $this->Controller->request->expects($this->any())->method('accepts')->will($this->returnValue(array('application/json')));
     $this->RequestHandler->initialize($event);
     $this->assertNull($this->RequestHandler->ext);
     call_user_func_array(array('Cake\\Routing\\Router', 'parseExtensions'), [$extensions, false]);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:17,代码来源:RequestHandlerComponentTest.php

示例13: function

 * to set as the default:
 *
 * - Route
 * - InflectedRoute
 * - DashedRoute
 *
 * If no call is made to `Router::defaultRouteClass`, the class used is
 * `Route` (`Cake\Routing\Route\Route`)
 *
 * Note that `Route` does not do any inflections on URLs which will result in
 * inconsistently cased URLs when used with `:plugin`, `:controller` and
 * `:action` markers.
 *
 */
Router::defaultRouteClass('Route');
Router::extensions(['json', 'xml', 'text', 'html']);
Router::scope('/', function ($routes) {
    /**
     * Here, we are connecting '/' (base path) to a controller called 'Pages',
     * its action called 'display', and we pass a param to select the view file
     * to use (in this case, src/Template/Pages/home.ctp)...
     */
    $routes->connect('/', ['controller' => 'Export', 'action' => 'test']);
    /**
     * ...and connect the rest of 'Pages' controller's URLs.
     */
    $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
    /**
     * Connect catchall routes for all controllers.
     *
     * Using the argument `InflectedRoute`, the `fallbacks` method is a shortcut for
开发者ID:Kaju-Bubanja,项目名称:GSOA,代码行数:31,代码来源:routes.php

示例14:

<?php

use Cake\Routing\Router;
Router::extensions('csv');
开发者ID:friendsofcake,项目名称:cakephp-csvview,代码行数:4,代码来源:routes.php

示例15:

<?php

use Cake\Routing\Router;
Router::extensions(['rss']);
开发者ID:jxav,项目名称:cakephp-feed,代码行数:4,代码来源:bootstrap.php


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