Used to set configuration parameters for the Dispatcher.
public static config ( array $config = [] ) : array | ||
$config | array | Possible key settings are `'classes'` which sets the class dependencies for `Dispatcher` (i.e. `'request'` or `'router'`) and `'rules'`, which sets the pre-processing rules for routing parameters. For more information on the `'rules'` setting, see the `$_rules` property. |
return | array | If no parameters are passed, returns an associative array with the current configuration, otherwise returns `null`. |
public function testPluginControllerLookupFail() { Dispatcher::config(array('classes' => array('router' => __CLASS__))); $this->expectException("/Controller `some_invalid_plugin.Controller` not found/"); Dispatcher::run(new Request(array('url' => '/plugin'))); }
* see the `Router` and `Route` classes. * * @see lithium\net\http\Router * @see lithium\net\http\Route */ use lithium\net\http\Router; use lithium\core\Environment; use lithium\action\Dispatcher; // Set the evironment if ($_SERVER['HTTP_HOST'] == 'li3bootstrap.dev.local' || $_SERVER['HTTP_HOST'] == 'li3bootstrap.local' || $_SERVER['HTTP_HOST'] == 'localhost') { Environment::set('development'); } /** * Dispatcher rules to rewrite admin actions. */ Dispatcher::config(array('rules' => array('admin' => array('action' => 'admin_{:action}')))); /** * "/admin" is the prefix for all Lithium Bootstrap admin routes. * Any "plugin" or library written for use with Lithium Bootstrap can utilize these routes * without needing to write any additional routes in most cases as this handles the basic CRUD. * It also handles pagination. * * Admin pages can be added to the main app's "/views/_libraries/li3b_core/pages" directory * and are accessible viw /admin/page/{:args} * * NOTE: li3b_core has no controller other than the pages controller. Other libraries and the * main application are where controllers belong. li3b_core is just the skeleton and assumes * no functionality. Static pages are as far as it goes. */ Router::connect("/admin", array('admin' => true, 'controller' => 'pages', 'action' => 'view', 'args' => array()), array('persist' => array('controller', 'admin'))); Router::connect("/admin/page/{:args}", array('admin' => true, 'controller' => 'pages', 'action' => 'view', 'args' => array()), array('persist' => array('controller', 'admin')));