Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?php
/**
* Continuation routing examples. Handles URLs in the following forms:
*
* /posts
* /en/posts
* /admin/posts
* /admin/en/posts
* /admin/en/posts.json
* /admin/en/posts/4ef16ccc7f8b9aa331000064.json
* /admin/posts/4ef16ccc7f8b9aa331000064.json
* /en/posts/edit/4ef16ccc7f8b9aa331000064
* /posts/4ef16ccc7f8b9aa331000064
*
* ...as well as many, many other permutations.
*/
use lithium\net\http\Router;
use lithium\core\Environment;
use lithium\action\Dispatcher;
/**
* Add a Dispatcher rule to rewrite actions with prefixes whenever the `admin` flag is encountered
* in parameters returned from routing.
*/
Dispatcher::config(array('rules' => array(
'admin' => array('action' => 'admin_{:action}')
)));
/**
* Continuation route for admin requests. Instead of dispatching to `{Controller}::{action}()`,
* matching routes will dispatch to `{Controller}::admin_{action}()`, per the dispatch rules
* defined above.
*/
Router::connect('/admin/{:args}', array('admin' => true), array(
'continue' => true, 'persist' => array('controller', 'admin')
));
/**
* Continuation routes for locale detection. Make sure to include `bootstrap/g11n.php`
* and configure your locales.
*/
Router::connect(
'/{:locale:' . join('|', array_keys(Environment::get('locales'))) . '}/{:args}',
array(),
array('continue' => true)
);
/**
* Static pages.
*/
Router::connect('/', 'Pages::view');
Router::connect('/pages/{:args}', 'Pages::view');
/**
* Handling API output formats.
*/
Router::connect('/{:args}.{:type:json|rss|xml}', array(), array('continue' => true));
/**
* MongoDB document routes.
*/
Router::connect('/{:controller}/{:id:[0-9a-f]{24}}', array('action' => 'view'));
Router::connect('/{:controller}/{:action}/{:id:[0-9a-f]{24}}');
/**
* Default route.
*/
Router::connect('/{:controller}/{:action}/{:args}');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.