Skip to content

Commit

Permalink
remove the prefix routing force param if the current prefix is alread…
Browse files Browse the repository at this point in the history
…y being used
  • Loading branch information
dogmatic69 committed Jan 16, 2013
1 parent 9e6b019 commit 2cdb810
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Core/Routes/Routing/InfinitasRouter.php
Expand Up @@ -46,8 +46,7 @@ class InfinitasRouter extends Router {
public static function connect($route, $defaults = array(), $options = array()) {
if (empty($options['routeClass'])) {
$options['routeClass'] = 'InfinitasRoute';
}
else {
} else {
if ($options['routeClass'] != 'PluginShortRoute') {
var_dump($options);
exit;
Expand Down Expand Up @@ -165,20 +164,40 @@ public static function url($url = null, $full = true) {
* Allows other plugins to register routes to be used in the app and builds
* the routes from the database.
*
* If the route has been specified to force a particular prefix but the requested url matches the
* prefix already it will be ignored.
*
* eg: forcing admin prefix on /admin/* url will remove admin => true from the router connect.
*
* @return void
*/
protected static function _buildRoutes() {
App::uses('ClassRegistry', 'Utility');
EventCore::trigger(new StdClass(), 'setupRoutes');

$CakeRequest = new CakeRequest();
$admin = false;
if (strstr($CakeRequest->here, '/admin') === 0) {
$admin = true;
}

if (InfinitasPlugin::infinitasInstalled()) {
$routes = ClassRegistry::init('Routes.Route')->getRoutes();
if (!empty($routes)) {
foreach ($routes as $route ) {
foreach ($routes as $route) {
if (false) {
debugRoute($route);
continue;
}
if (array_key_exists('admin', $route['Route']['values'])) {
if (!$admin && !$route['Route']['values']['admin']) {
unset($route['Route']['values']['admin']);
}

if ($admin && $route['Route']['values']['admin']) {
unset($route['Route']['values']['admin']);
}
}

call_user_func_array(array('InfinitasRouter', 'connect'), $route['Route']);
}
Expand Down

0 comments on commit 2cdb810

Please sign in to comment.