本文整理汇总了PHP中Cake\Routing\DispatcherFactory::add方法的典型用法代码示例。如果您正苦于以下问题:PHP DispatcherFactory::add方法的具体用法?PHP DispatcherFactory::add怎么用?PHP DispatcherFactory::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Routing\DispatcherFactory
的用法示例。
在下文中一共展示了DispatcherFactory::add方法的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();
}
示例2: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('App.namespace', 'TestApp');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
$this->_init();
}
示例3: testDispatcherFactoryCompat
/**
* Ensure that filters connected to the DispatcherFactory are
* also applied
*/
public function testDispatcherFactoryCompat()
{
$filter = $this->getMock('Cake\\Routing\\DispatcherFilter', ['beforeDispatch', 'afterDispatch']);
DispatcherFactory::add($filter);
$dispatcher = new ActionDispatcher();
$this->assertCount(1, $dispatcher->getFilters());
$this->assertSame($filter, $dispatcher->getFilters()[0]);
}
示例4: setUp
/**
* Setup method
*
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('App.namespace', 'TestApp');
Router::connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);
DispatcherFactory::clear();
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
}
示例5: setUp
/**
* Setup
*
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('App.namespace', 'TestApp');
Security::salt('not-the-default');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
$this->object = $this->getObjectForTrait('Cake\\Routing\\RequestActionTrait');
Router::connect('/request_action/:action/*', ['controller' => 'RequestAction']);
Router::connect('/tests_apps/:action/*', ['controller' => 'TestsApps']);
}
示例6:
<?php
/**
* 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\Core\Configure;
use Cake\Routing\DispatcherFactory;
use Settings\Core\Setting;
# Configures
Configure::write('AB.Show', true);
Configure::write('Settings.Prefixes.AB', 'AdminBar');
# Settings
Setting::register('AB.Backend', true, ['type' => 'select', 'options' => [0 => 'Disabled', 1 => 'Enabled']]);
Setting::register('AB.Frontend', true, ['type' => 'select', 'options' => [0 => 'Disabled', 1 => 'Enabled']]);
# AdminBar
Configure::write('AdminBar.goto_backend', ['on' => ['prefix' => ['!admin', '*'], 'controller' => '*', 'action' => '*'], 'label' => 'CakeAdmin Panel', 'url' => '/admin']);
Configure::write('AdminBar.goto_website', ['on' => ['prefix' => 'admin', 'controller' => '*', 'action' => '*'], 'label' => 'Go To Website', 'url' => Configure::read('App.fullBaseUrl')]);
Configure::write('AdminBar.goto_settings', ['on' => ['prefix' => 'admin', 'controller' => '*', 'action' => '*'], 'label' => 'Settings', 'url' => ['prefix' => 'admin', 'plugin' => 'CakeAdmin', 'controller' => 'Settings', 'action' => 'index']]);
# Dispatcher Filter
DispatcherFactory::add('AdminBar.AdminBar');
示例7: testCreate
/**
* Test creating a dispatcher with the factory
*
* @return void
*/
public function testCreate()
{
$mw = $this->getMock('Cake\\Routing\\DispatcherFilter', ['beforeDispatch']);
DispatcherFactory::add($mw);
$result = DispatcherFactory::create();
$this->assertInstanceOf('Cake\\Routing\\Dispatcher', $result);
$this->assertCount(1, $result->filters());
}
示例8:
*/
/**
* Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
* Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
* advanced ways of loading plugins
*
* Plugin::loadAll(); // Loads all plugins at once
* Plugin::load('Migrations'); //Loads a single plugin named Migrations
*
*/
//Plugin::load('Crud');
Plugin::load('Migrations');
Plugin::load('FOC/Authenticate');
// Only try to load DebugKit in development mode
// Debug Kit should not be installed on a production system
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
/**
* Connect middleware/dispatcher filters.
*/
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
DispatcherFactory::add('REST', ['priority' => 1]);
/**
* Enable default locale format parsing.
* This is needed for matching the auto-localized string output of Time() class when parsing dates.
*/
Type::build('date')->useLocaleParser();
Type::build('datetime')->useLocaleParser();
示例9:
* Inflector::rules('uninflected', ['dontinflectme']);
* Inflector::rules('transliteration', ['/å/' => 'aa']);
*/
/**
* Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
* Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
* advanced ways of loading plugins
*
* Plugin::loadAll(); // Loads all plugins at once
* Plugin::load('Migrations'); //Loads a single plugin named Migrations
*
*/
Plugin::loadAll();
Plugin::load('Migrations');
// Only try to load DebugKit in development mode
// Debug Kit should not be installed on a production system
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
/**
* Connect middleware/dispatcher filters.
*/
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
DispatcherFactory::add('Acesso');
/**
* Enable default locale format parsing.
* This is needed for matching the auto-localized string output of Time() class when parsing dates.
*/
Type::build('datetime')->useLocaleParser();
示例10: setupBeforeClass
/**
* test case startup
*
* @return void
*/
public static function setupBeforeClass()
{
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
}
示例11:
* Inflector::rules('transliteration', ['/å/' => 'aa']);
*/
/**
* Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
* Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
* advanced ways of loading plugins
*
* Plugin::loadAll(); // Loads all plugins at once
* Plugin::load('Migrations'); //Loads a single plugin named Migrations
*
*/
Plugin::load('Migrations');
Plugin::load('Bootstrap');
// Only try to load DebugKit in development mode
// Debug Kit should not be installed on a production system
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
/**
* Connect middleware/dispatcher filters.
*/
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
DispatcherFactory::add('LocaleSelector');
/**
* Enable default locale format parsing.
* This is needed for matching the auto-localized string output of Time() class when parsing dates.
*/
Type::build('date')->useLocaleParser();
Type::build('datetime')->useLocaleParser();
示例12:
<?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 Garderobe CakePHP 3 UI Plugin
* @since 0.0.1
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Event\EventManager;
use Cake\Core\Configure;
use Cake\Routing\DispatcherFactory;
EventManager::instance()->attach(new Garderobe\Core\Event\CoreEvent(), null);
DispatcherFactory::add('Garderobe/Core.Asset');
示例13: implode
* Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
* Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
* advanced ways of loading plugins
*
* Plugin::loadAll(); // Loads all plugins at once
* Plugin::load('Migrations'); //Loads a single plugin named Migrations
*
*/
Plugin::load('Migrations');
// Only try to load DebugKit in development mode
// Debug Kit should not be installed on a production system
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
/**
* Connect middleware/dispatcher filters.
*/
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
DispatcherFactory::add('LocaleSelector', ['locales' => ['pt-BR']]);
/**
* Enable default locale format parsing.
* This is needed for matching the auto-localized string output of Time() class when parsing dates.
*/
Type::build('date')->useLocaleParser()->setLocaleFormat('dd-M-y');
Type::build('datetime')->useLocaleParser();
/**
* Carregando o arquivo de tradução padrão
*/
require implode(DS, [__DIR__, '..', 'src', 'Template', 'translate.ctp']);
示例14: Switcher
<?php
/**
* Copyright (c) 2015 ELASTIC Consultants Inc. (https://elasticconsultants.com/)
*
* 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 (c) 2015, ELASTIC Consultatnts Inc. (https://elasticconsultants.com/)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Load filter
*/
use Cake\Routing\DispatcherFactory;
use TestDatasourceSwitcher\Routing\Filter\Switcher;
DispatcherFactory::add(new Switcher(['priority' => 1]));
示例15: file
<?php
use Cake\Core\Configure;
use Cake\Routing\DispatcherFactory;
use CookieWarning\Routing\Filter\CookieWarningFilter;
use CookieWarning\Validation\ConfigValidator;
$config = Configure::read('CookieWarning');
if ($config == null) {
throw new \Exception(__d('cookie_warning', 'Please add a configuration for the CookieWarning plugin in the app.php file (see readme in plugin folder)'));
}
// Validate the Configure Data
$validator = new ConfigValidator();
$errors = $validator->errors($config);
if (!empty($errors)) {
throw new \Exception(__d('cookie_warning', 'Délai d\'expiration du cookie incorrect'));
}
$filter = new CookieWarningFilter(['priority' => 9999]);
DispatcherFactory::add($filter);