Skip to content

Instantly share code, notes, and snippets.

@nexeck
Created October 2, 2011 10:02
Show Gist options
  • Save nexeck/1257299 to your computer and use it in GitHub Desktop.
Save nexeck/1257299 to your computer and use it in GitHub Desktop.
<?php
Route::set('cms', function($uri) {
if (empty($uri))
{
$default_route = Route::get('default');
$controller = Arr::get($default_route->defaults(), 'controller');
$action = Arr::get($default_route->defaults(), 'action');
return array(
'controller' => $controller,
'action' => $action,
);
}
if (class_exists('Controller_' . $uri))
{
return array(
'controller' => $uri,
'action' => 'index',
);
}
if (preg_match('/(?P<controller>\w+)\/(?P<action>\w+)/', $uri, $matches))
{
return array(
'controller' => $matches['controller'],
'action' => $matches['action'],
);
}
return array(
'controller' => 'cms',
'action' => 'page',
'slug' => $uri,
);
},
'<slug>'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment