コード例 #1
0
 /**
  * reset environment.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Plugin::load(array('TestPlugin', 'TestPluginTwo'));
     $this->Case = $this->getMockForAbstractClass('Cake\\TestSuite\\ControllerTestCase');
     $this->Case->loadRoutes = false;
     DispatcherFactory::add('Routing');
     DispatcherFactory::add('ControllerFactory');
     Router::scope('/', function ($routes) {
         $routes->fallbacks();
     });
     Router::prefix('admin', function ($routes) {
         $routes->plugin('TestPlugin', function ($routes) {
             $routes->fallbacks();
         });
         $routes->fallbacks();
     });
     Router::plugin('TestPlugin', function ($routes) {
         $routes->fallbacks();
     });
     Router::plugin('TestPluginTwo', function ($routes) {
         $routes->fallbacks();
     });
     TableRegistry::clear();
 }
コード例 #2
0
 /**
  * @return void
  */
 public function testBuildResetWithPlugin()
 {
     Router::connect('/:controller/:action/*');
     $result = $this->Url->buildReset(['controller' => 'foobar', 'action' => 'test']);
     $expected = '/foobar/test';
     $this->assertSame($expected, $result);
     $this->Url->request->here = '/admin/foo/bar/baz/test';
     $this->Url->request->params['prefix'] = 'admin';
     $this->Url->request->params['plugin'] = 'Foo';
     Router::reload();
     Router::connect('/:controller/:action/*');
     Router::plugin('Foo', function ($routes) {
         $routes->fallbacks();
     });
     Router::prefix('admin', function ($routes) {
         $routes->plugin('Foo', function ($routes) {
             $routes->fallbacks();
         });
     });
     Plugin::routes();
     Router::pushRequest($this->Url->request);
     $result = $this->Url->build(['controller' => 'bar', 'action' => 'baz', 'x']);
     $expected = '/admin/foo/bar/baz/x';
     $this->assertSame($expected, $result);
     $result = $this->Url->buildReset(['controller' => 'bar', 'action' => 'baz', 'x']);
     $expected = '/bar/baz/x';
     $this->assertSame($expected, $result);
 }
コード例 #3
0
 /**
  * Tests
  *
  * @return void
  */
 public function testResetLink()
 {
     Router::connect('/:controller/:action/*');
     $result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/foobar/test">Foo</a>';
     $this->assertEquals($expected, $result);
     $this->Html->request->here = '/admin/foobar/test';
     $this->Html->request->params['admin'] = true;
     $this->Html->request->params['prefix'] = 'admin';
     Router::reload();
     Router::connect('/:controller/:action/*');
     Router::prefix('admin', function ($routes) {
         $routes->connect('/:controller/:action/*');
     });
     $result = $this->Html->link('Foo', ['prefix' => 'admin', 'controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/admin/foobar/test">Foo</a>';
     $this->assertEquals($expected, $result);
     $result = $this->Html->link('Foo', ['controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/admin/foobar/test">Foo</a>';
     //debug($result);
     //$this->assertEquals($expected, $result);
     $result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/foobar/test">Foo</a>';
     $this->assertEquals($expected, $result);
 }
コード例 #4
0
ファイル: routes.default.php プロジェクト: gwhitcher/cakeblog
 * 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(DashedRoute::class);
Router::scope('/', function (RouteBuilder $routes) {
    $routes->connect('/', ['controller' => 'Pages', 'action' => 'home']);
    $routes->connect('/*', ['controller' => 'Articles', 'action' => 'view']);
    $routes->connect('/blog/*', ['controller' => 'Articles', 'action' => 'index']);
    $routes->connect('/rss', ['controller' => 'Articles', 'action' => 'rss']);
    $routes->connect('/author/*', ['controller' => 'Author', 'action' => 'index']);
    $routes->connect('/category/*', ['controller' => 'Categories', 'action' => 'index']);
    $routes->connect('/search', ['controller' => 'Search', 'action' => 'index']);
    $routes->connect('/users/login', ['controller' => 'Users', 'action' => 'login']);
    $routes->connect('/users/logout', ['controller' => 'Users', 'action' => 'logout']);
    $routes->connect('/admin', ['controller' => 'Admin', 'action' => 'index']);
    $routes->connect('/install', ['controller' => 'Install', 'action' => 'index']);
    $routes->fallbacks(DashedRoute::class);
});
Router::prefix('admin', function ($routes) {
    // All routes here will be prefixed with `/admin`
    // And have the prefix => admin route element added
    $routes->redirect('/users/login', BASE_URL . '/users/login', ['status' => 302]);
    $routes->redirect('/users/logout', BASE_URL . '/users/logout', ['status' => 302]);
    $routes->fallbacks(DashedRoute::class);
});
Plugin::routes();
コード例 #5
0
/**
 * Adding routes for the admin-prefix and CakeManager-Plugin
 */
Router::prefix('admin', function ($routes) {
    $routes->plugin('CakeManager', ['path' => '/manager'], function ($routes) {
        $routes->fallbacks('InflectedRoute');
    });
    $routes->fallbacks('InflectedRoute');
});
/**
 * Adding routes for the api-prefix and CakeManager-Plugin
 */
Router::prefix('api', function ($routes) {
    $routes->plugin('CakeManager', ['path' => '/'], function ($routes) {
        $routes->extensions(['json']);
        $routes->resources('Roles');
        $routes->resources('Users');
        $routes->fallbacks('InflectedRoute');
    });
});
/*
 * Adding default routes for the CakeManager
 */
Router::plugin('CakeManager', ['path' => '/'], function ($routes) {
    $routes->fallbacks('InflectedRoute');
});
/**
 * Default routes for usersController from the CakeManager
 *
 * Previous:
 * manager/users/request
 *
コード例 #6
0
ファイル: routes.php プロジェクト: Campustop/devv2
 *
 */
Router::defaultRouteClass('DashedRoute');
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' => 'Home', 'action' => 'index']);
    /**
     * ...and connect the rest of 'Pages' controller's URLs.
     */
    $routes->connect('/pages/*', ['controller' => 'Home', 'action' => 'index']);
    Router::prefix('admin', function ($routes) {
        $routes->connect('/admin/*', ['controller' => 'Users', 'action' => 'dashboard']);
        $routes->fallbacks('InflectedRoute');
    });
    /**
     * 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
コード例 #7
0
ファイル: routes.php プロジェクト: crabstudio/app
     *
     * 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');
});
Router::prefix('admin', function ($routes) {
    $routes->connect('/', ['controller' => 'Dashboard', 'action' => 'index']);
    $routes->connect('/login', ['controller' => 'Users', 'action' => 'login']);
    $routes->connect('/logout', ['controller' => 'Users', 'action' => 'logout']);
    //Password recovery
    $routes->connect('/lost-password', ['controller' => 'Users', 'action' => 'lostPassword']);
    $routes->connect('/reset-password/:token/:email', ['controller' => 'Users', 'action' => 'resetPassword'], ['token' => '[a-z0-9]+', 'email' => '^[A-Za-z0-9._%+-]+@([A-Za-z0-9-]+\\.)+([A-Za-z0-9]{2,4}|museum)$', 'pass' => ['token', 'email']]);
    //Register account
    $routes->connect('/register', ['controller' => 'Users', 'action' => 'register']);
    $routes->connect('/active-account/:token/:email', ['controller' => 'Users', 'action' => 'activeAccount'], ['token' => '[a-z0-9]+', 'email' => '^[A-Za-z0-9._%+-]+@([A-Za-z0-9-]+\\.)+([A-Za-z0-9]{2,4}|museum)$', 'pass' => ['token', 'email']]);
    $routes->connect('/:controller', ['action' => 'index']);
    $routes->connect('/:controller/:action/*', []);
    $routes->fallbacks('DashedRoute');
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();
コード例 #8
0
<?php

use Cake\Routing\Router;
Router::prefix('admin', function ($routes) {
    $routes->connect('/feedbacks', ['plugin' => 'AkkaFeedback', 'controller' => 'Feedbacks', 'action' => 'index'], ['routeClass' => 'DashedRoute']);
    $routes->connect('/feedbacks/:action/*', ['plugin' => 'AkkaFeedback', 'controller' => 'Feedbacks'], ['routeClass' => 'DashedRoute']);
    $routes->plugin('AkkaFeedback', function ($routes) {
        $routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);
        $routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);
    });
});
Router::plugin('AkkaFeedback', ['path' => '/akka-feedback'], function ($routes) {
    $routes->fallbacks('DashedRoute');
});
コード例 #9
0
ファイル: routes.php プロジェクト: jngvmh/daklak4mua
     *
     * 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');
});
Router::prefix('admin', function ($routes) {
    // All routes here will be prefixed with `/admin`
    // And have the prefix => admin route element added.
    $routes->fallbacks('DashedRoute');
});
Router::prefix('mianst', function ($routes) {
    // All routes here will be prefixed with `/admin`
    // And have the prefix => admin route element added.
    $routes->fallbacks('DashedRoute');
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();
コード例 #10
0
ファイル: routes.php プロジェクト: AdBouli/hotel-manager
     *    `$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');
});
Router::prefix('admin', function ($routes) {
    $routes->connect('/', ['controller' => 'Reservations', 'action' => 'index', 'home']);
    $routes->fallbacks('DashedRoute');
});
Router::prefix('hotel', function ($routes) {
    $routes->connect('/', ['controller' => 'Reservations', 'action' => 'index', 'home']);
    $routes->fallbacks('DashedRoute');
});
Router::prefix('restau', function ($routes) {
    $routes->connect('/', ['controller' => 'Orders', 'action' => 'index', 'home']);
    $routes->fallbacks('DashedRoute');
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();
コード例 #11
0
ファイル: routes.php プロジェクト: CaoLP/truyen.haytuyet
 *
 */
Router::defaultRouteClass('Route');
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']);
    /**
     * ...and connect the rest of 'Pages' controller's URLs.
     */
    $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
    Router::prefix('Admin', function ($routes) {
        $routes->fallbacks('InflectedRoute');
    });
    /**
     * Connect catchall routes for all controllers.
     *
     * Using the argument `InflectedRoute`, the `fallbacks` method is a shortcut for
     *    `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);`
     *    `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);`
     *
     * 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
コード例 #12
0
ファイル: routes.php プロジェクト: aansubarkah/ppni-server
     * 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');
});
//Router::scope('/', function ($routes) {
Router::prefix('api', function ($routes) {
    /**
     * we are add 'api' as a prefix for all url
     */
    $routes->extensions(['json', 'xml']);
    $routes->resources('Users');
    $routes->resources('Hierarchies');
    $routes->resources('Dispositions');
    $routes->fallbacks('InflectedRoute');
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();
コード例 #13
0
ファイル: routes.php プロジェクト: jxav/cakephp-cakeadmin
/**
 * CakeManager (http://cakemanager.org)
 * Copyright (c) http://cakemanager.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) http://cakemanager.org
 * @link          http://cakemanager.org CakeManager Project
 * @since         1.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
use Cake\Routing\Router;
Router::prefix('admin', function ($routes) {
    $routes->connect('/', ['plugin' => 'CakeAdmin', 'controller' => 'Users', 'action' => 'login']);
    $routes->fallbacks('InflectedRoute');
});
Router::plugin('CakeAdmin', ['path' => '/'], function ($routes) {
    $routes->prefix('admin', function ($routes) {
        $routes->connect('/login', ['controller' => 'Users', 'action' => 'login']);
        $routes->connect('/logout', ['controller' => 'Users', 'action' => 'logout']);
        $routes->connect('/posttypes/:type/:action/*', ['controller' => 'PostTypes'], ['pass' => ['type']]);
        $routes->connect('/', ['controller' => 'Users', 'action' => 'login']);
        $routes->connect('/users/:action/*', ['controller' => 'Users']);
        $routes->connect('/dashboard', ['controller' => 'Dashboard']);
        $routes->connect('/notifications/**', ['controller' => 'Notifications']);
        $routes->connect('/settings/**', ['controller' => 'Settings']);
        $routes->fallbacks('InflectedRoute');
    });
});
コード例 #14
0
 * 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.
 */
Router::prefix('api', function ($routes) {
    $routes->extensions(['json', 'xml']);
    //$routes->connect('/:controller');
    $routes->resources('Requirements', ['id' => '[0-9A-Za-z]+']);
});
//$routes->fallbacks('DashedRoute');
//});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();
/*$routes = Router::routes();
echo('<pre>'); // Readable output
var_dump($routes);
echo('</pre>');*/
コード例 #15
0
ファイル: routes.php プロジェクト: NatDls/BiellesMeusiennes
    /*
     * Routes amenant a l'inscription à un évènement d'un nouvel utilisateur
     */
    $routes->connect('/evenement/:slug.:id', ['controller' => 'Events', 'action' => 'inscription'], ['_name' => 'form-inscription', 'pass' => ['id', 'slug'], 'id' => '[0-9]+']);
    /**
     * 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');
});
Router::prefix('Admin', function ($routes) {
    $routes->connect('/', ['controller' => 'Pages', 'action' => 'dashboard', 'prefix' => 'admin'], ['_name' => 'Dashboard']);
    $routes->fallbacks('DashedRoute');
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();
コード例 #16
0
<?php

use Cake\Routing\Router;
Router::prefix('admin', function ($routes) {
    /**
     * ...and connect the rest of 'Pages' controller's URLs.
     */
    $routes->connect('/EasyMenus', ['plugin' => 'EasyMenus', 'controller' => 'EasyMenus', 'action' => 'index']);
    $routes->connect('/EasyMenus/menu-settings', ['plugin' => 'EasyMenus', 'controller' => 'EasyMenus', 'action' => 'menuSettings']);
    $routes->connect('/EasyMenus/add', ['plugin' => 'EasyMenus', 'controller' => 'EasyMenus', 'action' => 'add']);
    $routes->connect('/EasyMenus/:id/view', ['plugin' => 'EasyMenus', 'controller' => 'EasyMenus', 'action' => 'view'], ['pass' => ['id']]);
    $routes->connect('/EasyMenus/:id/edit', ['plugin' => 'EasyMenus', 'controller' => 'EasyMenus', 'action' => 'edit'], ['pass' => ['id']]);
    $routes->connect('/EasyMenus/:id/delete', ['plugin' => 'EasyMenus', 'controller' => 'EasyMenus', 'action' => 'delete'], ['pass' => ['id']]);
});
コード例 #17
0
<?php

/**
* 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) Mindforce Team (http://mindforce.me)
* @link          http://mindforce.me RearEngine CakePHP 3 Plugin
* @since         0.0.1
* @license       http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Routing\Router;
/* Front default routes */
Router::scope('/', function ($routes) {
    $routes->plugin('RearEngine', function ($routes) {
        $routes->fallbacks('DashedRoute');
    });
});
/* Admin default routes */
Router::prefix('admin', function ($routes) {
    //enable app default admin routes
    $routes->fallbacks('DashedRoute');
    //RearEngine default routes
    $routes->plugin('RearEngine', function ($routes) {
        $routes->fallbacks('DashedRoute');
    });
    //RearEngine custom routes
    $routes->connect('/', ['plugin' => 'RearEngine', 'controller' => 'Dashboards', 'action' => 'index']);
    $routes->connect('/settings', ['plugin' => 'RearEngine', 'controller' => 'Settings', 'action' => 'index']);
});
コード例 #18
0
ファイル: routes.php プロジェクト: alaxos/alaskyzer
    /**
     * Connect catchall routes for all controllers.
     *
     * Using the argument `InflectedRoute`, the `fallbacks` method is a shortcut for
     *    `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);`
     *    `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);`
     *
     * 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('InflectedRoute');
});
Router::prefix('admin', function ($routes) {
    $routes->extensions(['json', 'xml', 'js']);
    $routes->fallbacks();
});
Router::prefix('api', function ($routes) {
    $routes->extensions(['json']);
    $routes->fallbacks();
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();
コード例 #19
0
<?php

use Cake\Routing\Router;
Router::prefix('admin', function ($routes) {
    $routes->plugin('PostTypes', ['path' => '/posttypes'], function ($routes) {
        $routes->connect('/:type/:action/*', ['controller' => 'PostTypes'], ['pass' => ['type']]);
        $routes->fallbacks('InflectedRoute');
    });
    $routes->fallbacks('InflectedRoute');
});
Router::prefix('api', function ($routes) {
    $routes->plugin('PostTypes', ['path' => '/posttypes'], function ($routes) {
        $routes->extensions(['json']);
        $routes->connect('/:type/:action/*', ['controller' => 'PostTypes'], ['pass' => ['type']]);
        $routes->resources('PostTypes');
        $routes->fallbacks('InflectedRoute');
    });
});
コード例 #20
0
<?php

use Cake\Routing\Router;
Router::prefix('admin', function ($routes) {
    $routes->plugin('Seo', function ($routes) {
        $routes->fallbacks('DashedRoute');
    });
});
コード例 #21
0
ファイル: routes.php プロジェクト: dereuromark/cakephp-data
<?php

namespace Data\Config;

use Cake\Routing\Route\DashedRoute;
use Cake\Routing\Router;
Router::prefix('admin', function ($routes) {
    $routes->plugin('Data', function ($routes) {
        $routes->connect('/:controller', ['action' => 'index'], ['routeClass' => DashedRoute::class]);
        $routes->connect('/:controller/:action/*', [], ['routeClass' => DashedRoute::class]);
    });
});
Router::plugin('Data', function ($routes) {
    $routes->connect('/:controller', ['action' => 'index'], ['routeClass' => DashedRoute::class]);
    $routes->connect('/:controller/:action/*', [], ['routeClass' => DashedRoute::class]);
});
コード例 #22
0
ファイル: RouterTest.php プロジェクト: rashmi/newrepo
 /**
  * Test that prefix() accepts options
  *
  * @return void
  */
 public function testPrefixOptions()
 {
     Router::prefix('admin', ['param' => 'value'], function ($routes) {
         $this->assertInstanceOf('Cake\\Routing\\RouteBuilder', $routes);
         $this->assertEquals('/admin', $routes->path());
         $this->assertEquals(['prefix' => 'admin', 'param' => 'value'], $routes->params());
     });
 }
コード例 #23
0
ファイル: routes.php プロジェクト: lecaoquochung/mediax-api
Router::defaultRouteClass('DashedRoute');
/*------------------------------------------------------------------------------------------------------------
 * api route json
 *
 * @input		
 * @output
 * 
 * @author		Le Hung <*****@*****.**>
 * @license		http://www.opensource.org/licenses/mit-license.php The MIT License
 * @created		201512
 -------------------------------------------------------------------------------------------------------------*/
// Router::extensions(['json', 'xml']); // test api no route
Router::prefix('api', function ($routes) {
    $routes->extensions(['json', 'xml']);
    $routes->resources('Ranklogs');
    $routes->resources('Users');
    Router::connect('/api/users/register', ['controller' => 'Users', 'action' => 'add', 'prefix' => 'api']);
    $routes->fallbacks('InflectedRoute');
});
Router::scope('/', function ($routes) {
    /*------------------------------------------------------------------------------------------------------------
     * api route Ranklogs
     *
     * @input		
     * @output
     * 
     * @author		Le Hung <*****@*****.**>
     * @license		http://www.opensource.org/licenses/mit-license.php The MIT License
     * @created		201512
     -------------------------------------------------------------------------------------------------------------*/
    // $routes->resources('Ranklogs'); // test api no route
コード例 #24
0
<?php

use Cake\Routing\Router;
Router::scope('/', ['plugin' => 'FrontEngine'], function ($routes) {
    $routes->connect('/', ['controller' => 'Home', 'action' => 'index']);
});
Router::prefix('admin', function ($routes) {
    $routes->plugin('FrontEngine', function ($routes) {
        $routes->fallbacks('DashedRoute');
    });
    $routes->connect('/menus', ['plugin' => 'FrontEngine', 'controller' => 'Menus', 'action' => 'index']);
    $routes->connect('/menus/:action/*', ['plugin' => 'FrontEngine', 'controller' => 'Menus']);
    $routes->connect('/links', ['plugin' => 'FrontEngine', 'controller' => 'Links', 'action' => 'index']);
    $routes->connect('/links/:action/*', ['plugin' => 'FrontEngine', 'controller' => 'Links']);
});
コード例 #25
0
ファイル: routes.php プロジェクト: Piclebeuh/API_cakephp3
 * - 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('DashedRoute');
Router::prefix('api', function ($routes) {
    $routes->extensions(['json', 'xml']);
    $routes->resources('Cocktails');
    $routes->resources('Logins');
    $routes->fallbacks('InflectedRoute');
});
Router::scope('/', function ($routes) {
    $routes->resources('Cocktails');
    $routes->resources('Logins');
    /**
     * 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']);
    /**
     * ...and connect the rest of 'Pages' controller's URLs.
     */
    $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
コード例 #26
0
ファイル: routes.php プロジェクト: augustovs/l2_teste
    /**
     * ...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
     *    `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);`
     *    `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);`
     *
     * 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('InflectedRoute');
});
Router::prefix('admin', function ($routes) {
    $routes->connect('/', ['controller' => 'Accounts', 'action' => 'index']);
    $routes->fallbacks('InflectedRoute');
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();
コード例 #27
0
ファイル: routes.php プロジェクト: BallStateCBER/cri
 * @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
 */
use Cake\Core\Plugin;
use Cake\Routing\Router;
Router::defaultRouteClass('DashedRoute');
Router::prefix('admin', function ($routes) {
    $routes->extensions(['json']);
    $routes->connect('/guide', ['controller' => 'Pages', 'action' => 'guide']);
    $routes->connect('/choose_client', ['controller' => 'Users', 'action' => 'chooseClient']);
    $routes->fallbacks('DashedRoute');
});
Router::prefix('client', function ($routes) {
    $routes->connect('/home', ['controller' => 'Communities', 'action' => 'index']);
    $routes->redirect('/', ['controller' => 'Communities', 'action' => 'index']);
    $routes->fallbacks('DashedRoute');
});
Router::scope('/', function ($routes) {
    $routes->connect('/', ['controller' => 'Pages', 'action' => 'home']);
    $routes->connect('/glossary', ['controller' => 'Pages', 'action' => 'glossary']);
    $routes->connect('/credits', ['controller' => 'Pages', 'action' => 'credits']);
    $routes->connect('/enroll', ['controller' => 'Pages', 'action' => 'enroll']);
    $routes->connect('/fasttrack', ['controller' => 'Pages', 'action' => 'fasttrack']);
    $routes->connect('/faq', ['controller' => 'Pages', 'action' => 'home']);
    $routes->connect('/communityFAQ', ['controller' => 'Pages', 'action' => 'faqCommunity']);
    $routes->connect('/consultantFAQ', ['controller' => 'Pages', 'action' => 'faqConsultants']);
    $routes->connect('/clear-cache', ['controller' => 'Pages', 'action' => 'clearCache']);
    $routes->redirect('/consultantfaq', '/consultantFAQ');
    $routes->redirect('/communityfaq', '/communityFAQ');
    $routes->connect('/login', ['controller' => 'Users', 'action' => 'login']);
コード例 #28
0
<?php

use Cake\Core\Plugin;
use Cake\Routing\Router;
Router::defaultRouteClass('DashedRoute');
Router::prefix('admin', function ($routes) {
    $routes->connect('/', ['controller' => 'Dashboard', 'action' => 'home']);
    $routes->connect('/login', ['controller' => 'Users', 'action' => 'login']);
    $routes->connect('/logout', ['controller' => 'Users', 'action' => 'logout']);
    $routes->connect('/:controller', ['action' => 'index']);
    $routes->connect('/:controller/:action/*');
});
Router::scope('/', function ($routes) {
    $routes->connect('/', ['controller' => 'Pages', 'action' => 'index']);
    $routes->connect('/login', ['controller' => 'Users', 'action' => 'login']);
    $routes->connect('/logout', ['controller' => 'Users', 'action' => 'logout']);
    $routes->connect('/register', ['controller' => 'Users', 'action' => 'add']);
    $routes->connect('/profile', ['controller' => 'Users', 'action' => 'profile']);
    $routes->connect('/:controller', ['action' => 'index']);
    $routes->connect('/:controller/:action/*');
    $routes->fallbacks('DashedRoute');
});
Plugin::routes();
コード例 #29
0
ファイル: AuthComponentTest.php プロジェクト: Rabp9/test-psi2
 /**
  * testLoginActionRedirect method
  *
  * @return void
  * @triggers Controller.startup $this->Controller
  */
 public function testLoginActionRedirect()
 {
     $event = new Event('Controller.startup', $this->Controller);
     Router::reload();
     Router::prefix('admin', function ($routes) {
         $routes->fallbacks('InflectedRoute');
     });
     Router::scope('/', function ($routes) {
         $routes->fallbacks('InflectedRoute');
     });
     $url = '/admin/auth_test/login';
     $request = $this->Auth->request;
     $request->addParams(['plugin' => null, 'controller' => 'auth_test', 'action' => 'login', 'prefix' => 'admin', 'pass' => []])->addPaths(['base' => null, 'here' => $url, 'webroot' => '/']);
     $request->url = ltrim($url, '/');
     Router::setRequestInfo($request);
     $this->Auth->config('loginAction', ['prefix' => 'admin', 'controller' => 'auth_test', 'action' => 'login']);
     $this->Auth->startup($event);
     $this->assertNull($this->Controller->testUrl);
 }
コード例 #30
0
ファイル: routes.php プロジェクト: abhi91tripathi/school_club
     */
    $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
    /**
     * Connect catchall routes for all controllers.
     *
     * Using the argument `InflectedRoute`, the `fallbacks` method is a shortcut for
     *    `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);`
     *    `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);`
     *
     * 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('InflectedRoute');
});
Router::prefix('admin', function ($routes) {
    $routes->fallbacks();
});
Router::prefix('school', function ($routes) {
    $routes->fallbacks();
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();