Skip to content

Commit

Permalink
enable PluginDot for routeClass parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
rchavik committed Sep 12, 2012
1 parent 99b798f commit 0cae19a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Cake/Routing/Router.php
Expand Up @@ -304,7 +304,12 @@ public static function connect($route, $defaults = array(), $options = array())
}
$routeClass = self::$_routeClass;
if (isset($options['routeClass'])) {
$routeClass = self::_validateRouteClass($options['routeClass']);
if (strpos($options['routeClass'], '.') === false) {
$routeClass = $options['routeClass'];
} else {
list($plugin, $routeClass) = pluginSplit($options['routeClass'], true);
}
$routeClass = self::_validateRouteClass($routeClass);
unset($options['routeClass']);
}
if ($routeClass == 'RedirectRoute' && isset($defaults['redirect'])) {
Expand Down
20 changes: 20 additions & 0 deletions lib/Cake/Test/Case/Routing/RouterTest.php
Expand Up @@ -2282,6 +2282,26 @@ public function testUsingCustomRouteClass() {
$this->assertEquals($expected, $result);
}

/**
* test using custom route class in PluginDot notation
*/
public function testUsingCustomRouteClassPluginDotSyntax() {
App::build(array(
'Plugin' => array(
CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS
)
));
CakePlugin::load('TestPlugin');
App::uses('TestRoute', 'TestPlugin.Routing/Route');
$routes = Router::connect(
'/:slug',
array('controller' => 'posts', 'action' => 'view'),
array('routeClass' => 'TestPlugin.TestRoute', 'slug' => '[a-z_-]+')
);
$this->assertInstanceOf('TestRoute', $routes[0]);
CakePlugin::unload('TestPlugin');
}

/**
* test that route classes must extend CakeRoute
*
Expand Down
@@ -0,0 +1,7 @@
<?php

App::uses('CakeRoute', 'Routing/Route');

class TestRoute extends CakeRoute {

}

0 comments on commit 0cae19a

Please sign in to comment.