本文整理汇总了PHP中Cake\Routing\DispatcherFactory类的典型用法代码示例。如果您正苦于以下问题:PHP DispatcherFactory类的具体用法?PHP DispatcherFactory怎么用?PHP DispatcherFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DispatcherFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
DispatcherFactory::clear();
$this->_init();
unset($this->RequestHandler, $this->Controller);
}
示例2: tearDown
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
Plugin::unload();
DispatcherFactory::clear();
$this->Case->controller = null;
}
示例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: __construct
/**
* @param \Spekkoek\ControllerFactory $factory A controller factory instance.
*/
public function __construct($factory = null)
{
// Compatibility with DispatcherFilters.
foreach (DispatcherFactory::filters() as $filter) {
$this->addFilter($filter);
}
$this->factory = $factory ?: new ControllerFactory();
}
示例5: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
DispatcherFactory::clear();
Router::reload();
Router::$initialized = false;
unset($this->RequestHandler, $this->Controller);
}
示例6: execute
/**
* Run a request and get the response.
*
* @param array $request The request context to execute.
* @return \Cake\Network\Response The generated response.
*/
public function execute($request)
{
$request = new Request($request);
$response = new Response();
$dispatcher = DispatcherFactory::create();
$dispatcher->eventManager()->on('Dispatcher.invokeController', ['priority' => 999], [$this->_test, 'controllerSpy']);
$dispatcher->dispatch($request, $response);
return $response;
}
示例7: 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');
}
示例8: index
/**
* Catch all for Opauth
* Handling callback
*/
public function index()
{
$this->_loadOpauth();
try {
$callback = ['validated' => true, 'response' => $this->Opauth->run()];
} catch (OpauthException $e) {
$callback = ['validated' => false, 'message' => $e->getMessage(), 'code' => $e->getCode()];
}
$Request = new Request(Configure::read('Opauth.CompleteURL'));
$Request->data = $callback;
$dispatcher = DispatcherFactory::create();
$dispatcher->dispatch($Request, new Response());
exit;
}
示例9: CakeRatchetFilter
<?php
use Cake\Core\Configure;
use Cake\Event\EventManager;
use Cake\Routing\DispatcherFactory;
use Cake\Routing\Router;
use CakeRatchet\Routing\Filter\CakeRatchetFilter;
$debugBar = new CakeRatchetFilter(EventManager::instance());
DispatcherFactory::add($debugBar);
示例10: tearDown
/**
* teardown
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
DispatcherFactory::clear();
Router::reload();
}
示例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: _sendRequest
/**
* Creates and send the request into a Dispatcher instance.
*
* Receives and stores the response for future inspection.
*
* @param string|array $url The URL
* @param string $method The HTTP method
* @param array|null $data The request data.
* @return void
* @throws \Exception
*/
protected function _sendRequest($url, $method, $data = [])
{
$request = $this->_buildRequest($url, $method, $data);
$response = new Response();
$dispatcher = DispatcherFactory::create();
$dispatcher->eventManager()->on('Dispatcher.beforeDispatch', ['priority' => 999], [$this, 'controllerSpy']);
try {
$dispatcher->dispatch($request, $response);
$this->_requestSession = $request->session();
$this->_response = $response;
} catch (PHPUnit_Exception $e) {
throw $e;
} catch (DatabaseException $e) {
throw $e;
} catch (Exception $e) {
$this->_exception = $e;
$this->_handleError($e);
}
}
示例14:
* 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');
// 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');
/**
* 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();
Plugin::load('BoxManager', ['bootstrap' => false, 'routes' => true]);
Plugin::load('SocialManager', ['bootstrap' => false, 'routes' => true]);
示例15: _shutdown
/**
* Run the shutdown events.
*
* Triggers the afterFilter and afterDispatch events.
*
* @return \Cake\Network\Response The response to serve.
*/
protected function _shutdown()
{
$this->controller->dispatchEvent('Controller.shutdown');
$dispatcher = DispatcherFactory::create();
$eventManager = $dispatcher->eventManager();
foreach ($dispatcher->filters() as $filter) {
$eventManager->attach($filter);
}
$args = ['request' => $this->controller->request, 'response' => $this->controller->response];
$result = $dispatcher->dispatchEvent('Dispatcher.afterDispatch', $args);
return $result->data['response'];
}