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


PHP Router::scope方法代码示例

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


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

示例1: setUp

 /**
  * 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();
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:31,代码来源:ControllerTestCaseTest.php

示例2: _init

 /**
  * init method
  *
  * @return void
  */
 protected function _init()
 {
     $request = new Request('controller_posts/index');
     $response = $this->getMock('Cake\\Network\\Response', ['_sendHeader', 'stop']);
     $this->Controller = new RequestHandlerTestController($request, $response);
     $this->RequestHandler = $this->Controller->components()->load('RequestHandler');
     $this->request = $request;
     Router::scope('/', function ($routes) {
         $routes->extensions('json');
         $routes->fallbacks('InflectedRoute');
     });
 }
开发者ID:Slayug,项目名称:castor,代码行数:17,代码来源:RequestHandlerComponentTest.php

示例3: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     TableRegistry::clear();
     Cache::disable();
     Router::reload();
     //Router::fullBaseUrl('http://test.local');
     Router::scope('/', function ($routes) {
         $routes->fallbacks('DashedRoute');
     });
     $this->Articles = TableRegistry::get('Articles', ['className' => 'Seo\\Test\\TestCase\\Model\\Behavior\\ArticlesTable']);
     $this->Articles->addBehavior('Seo.Seo', $this->defaultConfig);
     $this->SeoBehavior = new SeoBehavior($this->Articles, $this->defaultConfig);
     $this->setReflectionClassInstance($this->SeoBehavior);
     //$this->defaultReflectionTarget = $this->SeoBehavior; // (optional)
     $this->defaultEntity = $this->Articles->find()->first();
     $this->locale = I18n::locale();
 }
开发者ID:orgasmicnightmare,项目名称:cakephp-seo,代码行数:23,代码来源:SeoBehaviorTest.php

示例4: setUp

 /**
  * Setup the test case, backup the static object values so they can be restored.
  * Specifically backs up the contents of Configure and paths in App if they have
  * not already been backed up.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Ips = TableRegistry::get('TestApp.Ips');
     $this->Ips->schema()->columnType('ip', 'ip');
     Router::scope('/', function ($routes) {
         $routes->connect('/ips', ['controller' => 'Ips']);
         $routes->connect('/ips/add', ['controller' => 'Ips', 'action' => 'add']);
         $routes->connect('/ips/edit/:id', ['controller' => 'Ips', 'action' => 'edit'], ['pass' => ['id']]);
         $routes->connect('/ips/edit_when_always/:id', ['controller' => 'Ips', 'action' => 'editWhenAlways'], ['pass' => ['id']]);
         $routes->connect('/ips/edit_when_bad_value/:id', ['controller' => 'Ips', 'action' => 'editWhenBadValue'], ['pass' => ['id']]);
         $routes->connect('/ips/add_other_field', ['controller' => 'Ips', 'action' => 'addOtherField']);
         $routes->connect('/ips/edit_other_field/:id', ['controller' => 'Ips', 'action' => 'editOtherField'], ['pass' => ['id']]);
         $routes->connect('/ips/edit_other_field_when_always/:id', ['controller' => 'Ips', 'action' => 'editOtherFieldWhenAlways'], ['pass' => ['id']]);
         $routes->connect('/ips/edit_other_field_when_bad_value/:id', ['controller' => 'Ips', 'action' => 'editOtherFieldWhenBadValue'], ['pass' => ['id']]);
         $routes->connect('/ips/add_two_fields', ['controller' => 'Ips', 'action' => 'addTwoFields']);
         $routes->connect('/ips/edit_two_fields/:id', ['controller' => 'Ips', 'action' => 'editTwoFields'], ['pass' => ['id']]);
     });
 }
开发者ID:thefredfox,项目名称:cakephp-ip-behavior,代码行数:26,代码来源:IpBehaviorTest.php

示例5: function

<?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']);
});
开发者ID:mindforce,项目名称:cakephp-front-engine,代码行数:15,代码来源:routes.php

示例6: function

<?php

/**
 * Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
use Cake\Core\Configure;
use Cake\Routing\Router;
Router::plugin('CakeDC/Users', ['path' => '/users'], function ($routes) {
    $routes->fallbacks('DashedRoute');
});
$oauthPath = Configure::read('Opauth.path');
if (is_array($oauthPath)) {
    Router::scope('/auth', function ($routes) use($oauthPath) {
        $routes->connect('/*', $oauthPath);
    });
}
Router::connect('/accounts/validate/*', ['plugin' => 'CakeDC/Users', 'controller' => 'SocialAccounts', 'action' => 'validate']);
Router::connect('/profile/*', ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'profile']);
Router::connect('/login', ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
Router::connect('/logout', ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'logout']);
开发者ID:OrigamiStructures,项目名称:users,代码行数:26,代码来源:routes.php

示例7: function

<?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']);
});
开发者ID:mindforce,项目名称:cakephp-rear-engine,代码行数:31,代码来源:routes.php

示例8: function

<?php

/**
 * UnionCMS __PACKAGE__
 *
 * This file is part of the of the simple cms based on CakePHP 3.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package   __PACKAGE__
 * @license   MIT
 * @copyright MIT License http://www.opensource.org/licenses/mit-license.php
 * @link      https://github.com/UnionCMS/__PACKAGE__
 * @author    Sergey Kalistratov <kalistratov.s.m@gmail.com>
 */
use Cake\Routing\Router;
use Cake\Routing\RouteBuilder;
Router::defaultRouteClass('DashedRoute');
Router::scope('/', function (RouteBuilder $routes) {
    $routes->connect('/', ['controller' => 'Test', 'action' => 'index']);
    $routes->connect('/test/:action/*', ['controller' => 'Test']);
    $routes->fallbacks('DashedRoute');
});
Router::plugin('Union/Core', ['path' => '/'], function (RouteBuilder $routeBuilder) {
    $routeBuilder->prefix('admin', function (RouteBuilder $routeBuilder) {
        $routeBuilder->connect('/core/:controller/:action/*', []);
        $routeBuilder->connect('/dashboard', ['controller' => 'Union', 'action' => 'dashboard']);
        $routeBuilder->connect('/', ['controller' => 'Union', 'action' => 'dashboard']);
    });
});
开发者ID:UnionCMS,项目名称:Skeleton,代码行数:30,代码来源:routes.php

示例9: function

 */
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' => 'Pages', 'action' => 'home']);
    /**
     * ...and connect the rest of 'Pages' controller's URLs.
     */
    /**
     * 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');
});
/**
 * Load all plugin routes.  See the Plugin documentation on
开发者ID:Jurrieb,项目名称:Eendagdeals,代码行数:32,代码来源:routes.php

示例10: function

Router::scope('/', function ($routes) {
    /*------------------------------------------------------------------------------------------------------------
     * api route Ranklogs
     *
     * @input		
     * @output
     * 
     * @author		Le Hung <lecaoquochung@gmail.com>
     * @license		http://www.opensource.org/licenses/mit-license.php The MIT License
     * @created		201512
     -------------------------------------------------------------------------------------------------------------*/
    // $routes->resources('Ranklogs'); // test api no route
    /**
     * 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']);
    /**
     * 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');
});
开发者ID:lecaoquochung,项目名称:mediax-api,代码行数:40,代码来源:routes.php

示例11: function

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']);
    $routes->connect('/logout', ['controller' => 'Users', 'action' => 'logout']);
    $routes->connect('/update-contact', ['controller' => 'Users', 'action' => 'updateContact']);
    $routes->connect('/change-password', ['controller' => 'Users', 'action' => 'changePassword']);
    $routes->connect('/forgot-password', ['controller' => 'Users', 'action' => 'forgotPassword']);
    $routes->connect('/reset-password/*', ['controller' => 'Users', 'action' => 'resetPassword']);
    $routes->connect('/community/:id', ['controller' => 'Communities', 'action' => 'view'], ['id' => '\\d+', 'pass' => ['id']]);
    $routes->connect('/postback', ['controller' => 'Purchases', 'action' => 'postback']);
    $routes->connect('/surveys/get_survey_list', ['controller' => 'Surveys', 'action' => 'getSurveyList']);
    $routes->connect('/surveys/get_survey_url/*', ['controller' => 'Surveys', 'action' => 'getSurveyUrl']);
    $routes->connect('/surveys/check_survey_assignment/*', ['controller' => 'Surveys', 'action' => 'checkSurveyAssignment']);
    $routes->connect('/surveys/get_qna_ids/*', ['controller' => 'Surveys', 'action' => 'getQnaIds']);
    $routes->connect('/surveys/cron_import', ['controller' => 'Surveys', 'action' => 'cronImport']);
    // Redirect common bot requests to home page to keep requests from appearing in error log
    $routes->redirect('/admin.php', '/');
    $routes->redirect('/blog', '/');
    $routes->redirect('/blog/*', '/');
    $routes->redirect('/components/*', '/');
    $routes->redirect('/joomla', '/');
    $routes->redirect('/joomla/*', '/');
    $routes->redirect('/user', '/');
    $routes->redirect('/wordpress', '/');
    $routes->redirect('/wp', '/');
    $routes->redirect('/wp-login.php', '/');
    $routes->redirect('/xmlrpc.php', '/');
    $routes->redirect('/administrator/*', '/');
    $routes->fallbacks('DashedRoute');
});
开发者ID:BallStateCBER,项目名称:cri,代码行数:40,代码来源:routes.php

示例12: function

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']);
    $routes->connect('/logout', ['controller' => 'Users', 'action' => 'logout']);
    $routes->connect('/account', ['controller' => 'Users', 'action' => 'account']);
    $routes->connect('/admin', ['controller' => 'Users', 'action' => 'admin']);
    $routes->connect('/admin/advices', ['controller' => 'Users', 'action' => 'advices']);
    $routes->connect('/admin/listMatch', ['controller' => 'Users', 'action' => 'listMatch']);
    $routes->connect('/admin/addMatch', ['controller' => 'Users', 'action' => 'addMatch']);
    $routes->connect('/admin/addTicket', ['controller' => 'Users', 'action' => 'addTicket']);
    $routes->connect('/admin/updateMatch', ['controller' => 'Users', 'action' => 'updateMatch']);
    $routes->connect('/admin/updateTicket', ['controller' => 'Users', 'action' => 'updateTicket']);
    $routes->connect('/admin/updateAdvice', ['controller' => 'Users', 'action' => 'updateAdvice']);
    $routes->connect('/admin/editMatch', ['controller' => 'Users', 'action' => 'editMatch']);
    /**
     * 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');
});
开发者ID:laurentdamien,项目名称:sportlay,代码行数:44,代码来源:routes.php

示例13: function

use Cake\Routing\Router;
Router::scope('/', function ($routes) {
    /**
     * Enable RESTful routes for our controllers.
     */
    $routes->extensions(['json']);
    /**
     * Connect /dashboard URLs to DashboardsController and disable /dashboards route.
     */
    $routes->connect('/dashboards/*', ['controller' => null]);
    $routes->connect('/dashboard', ['controller' => 'Dashboards', 'action' => 'index'], ['routeClass' => 'InflectedRoute']);
    $routes->connect('/dashboard/:action/*', ['controller' => 'Dashboards'], ['routeClass' => 'InflectedRoute']);
    /**
     * 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']);
    /**
     * Connect a route for the index action of any controller.
     * And a more general catch all route for any action.
     * Using InflectedRoute so HtmlHelper::Link() will generate lowercase URL's
     */
    $routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);
    $routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);
    /**
     * Load all plugin routes.  See the Plugin documentation on
     * how to customize the loading of plugin routes.
     */
    Plugin::routes();
});
开发者ID:alt3,项目名称:cakebox-console,代码行数:31,代码来源:routes.php

示例14: _connectDefaultRoutes

 /**
  * Connect some fallback routes for testing router behavior.
  *
  * @return void
  */
 protected function _connectDefaultRoutes()
 {
     Router::scope('/', function ($routes) {
         $routes->fallbacks('InflectedRoute');
     });
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:11,代码来源:RouterTest.php

示例15: function

use Cake\Core\Plugin;
use Cake\Routing\Router;
Router::extensions(['json']);
Router::defaultRouteClass('InflectedRoute');
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' => 'Todos', 'action' => 'index']);
    /**
     * ...and connect the rest of 'Pages' controller's URLs.
     */
    $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
    /**
     * Connect a route for the index action of any controller.
     * And a more general catch all route for any action.
     *
     * The `fallbacks` method is a shortcut for
     *    `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);`
     *    `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);`
     *
     * You can remove these routes once you've connected the
     * routes you want in your application.
     */
    $routes->fallbacks();
});
/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
开发者ID:surjit,项目名称:todo,代码行数:32,代码来源:routes.php


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