diff --git a/lib/Cake/Controller/CakeErrorController.php b/lib/Cake/Controller/CakeErrorController.php index f55649672..7fd3b46f4 100644 --- a/lib/Cake/Controller/CakeErrorController.php +++ b/lib/Cake/Controller/CakeErrorController.php @@ -22,10 +22,8 @@ class CakeErrorController extends AppController { * @access public * @return void */ - function __construct() { - parent::__construct(); - $this->_set(Router::getPaths()); - $this->request = Router::getRequest(false); + function __construct($request = null) { + parent::__construct($request); $this->constructClasses(); $this->Components->trigger('initialize', array(&$this)); $this->_set(array('cacheAction' => false, 'viewPath' => 'errors')); diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index d5f34bc2f..1b0eb68fe 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -147,9 +147,9 @@ class ExceptionRenderer { if ($__previousError != $exception) { $__previousError = $exception; - $controller = new CakeErrorController(); + $controller = new CakeErrorController(Router::getRequest(false)); } else { - $controller = new Controller(); + $controller = new Controller(Router::getRequest(false)); $controller->viewPath = 'errors'; } return $controller; diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index b37350ba9..be0ebe77e 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -40,14 +40,6 @@ App::uses('Debugger', 'Utility'); */ class Dispatcher { -/** - * The request object - * - * @var CakeRequest - * @access public - */ - public $request = null; - /** * Response object used for asset/cached responses. * @@ -90,18 +82,16 @@ class Dispatcher { return; } - $this->request = $this->parseParams($request, $additionalParams); - $controller = $this->_getController($this->request); + $request = $this->parseParams($request, $additionalParams); + Router::setRequestInfo($request); + $controller = $this->_getController($request); - if (!is_object($controller)) { - Router::setRequestInfo($request); + if (!($controller instanceof Controller)) { throw new MissingControllerException(array( 'controller' => Inflector::camelize($request->params['controller']) . 'Controller' )); } - Router::setRequestInfo($request); - if ($this->_isPrivateAction($request)) { throw new PrivateActionException(array( 'controller' => Inflector::camelize($request->params['controller']) . "Controller", @@ -123,10 +113,8 @@ class Dispatcher { $privateAction = $request->params['action'][0] === '_'; $prefixes = Router::prefixes(); - if (!empty($prefixes)) { - if (isset($request->params['prefix'])) { - $request->params['action'] = $request->params['prefix'] . '_' . $request->params['action']; - } elseif (strpos($request->params['action'], '_') > 0) { + if (!$privateAction && !empty($prefixes)) { + if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) { list($prefix, $action) = explode('_', $request->params['action']); $privateAction = in_array($prefix, $prefixes); } @@ -303,13 +291,13 @@ class Dispatcher { if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) { $this->response->statusCode(404); $this->response->send(); - return $this->_stop(); + return true; } elseif ($isCss) { include WWW_ROOT . DS . $filters['css']; - $this->_stop(); + return true; } elseif ($isJs) { include WWW_ROOT . DS . $filters['js']; - $this->_stop(); + return true; } $controller = null; $pathSegments = explode('.', $url); diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 61d36d309..9261e7659 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -503,6 +503,9 @@ class Router { break; } } + if (isset($out['prefix'])) { + $out['action'] = $out['prefix'] . '_' . $out['action']; + } if (!empty($ext) && !isset($out['url']['ext'])) { $out['url']['ext'] = $ext; diff --git a/lib/Cake/View/MediaView.php b/lib/Cake/View/MediaView.php index 5cf348c3d..70e92979c 100644 --- a/lib/Cake/View/MediaView.php +++ b/lib/Cake/View/MediaView.php @@ -39,7 +39,7 @@ App::uses('CakeRequest', 'Network'); * {{{ * class ExampleController extends AppController { * function download () { - * $this->view = 'Media'; + * $this->viewClass = 'Media'; * $params = array( * 'id' => 'example.zip', * 'name' => 'example', diff --git a/lib/Cake/View/ThemeView.php b/lib/Cake/View/ThemeView.php index b3a9c6e85..df85282b7 100644 --- a/lib/Cake/View/ThemeView.php +++ b/lib/Cake/View/ThemeView.php @@ -23,7 +23,7 @@ App::uses('View', 'View'); * * Allows the creation of multiple themes to be used in an app. Theme views are regular view files * that can provide unique HTML and static assets. If theme views are not found for the current view - * the default app view files will be used. You can set `$this->theme` and `$this->view = 'Theme'` + * the default app view files will be used. You can set `$this->theme` and `$this->viewClass = 'Theme'` * in your Controller to use the ThemeView. * * Example of theme path with `$this->theme = 'super_hot';` Would be `app/views/themed/super_hot/posts` diff --git a/lib/Cake/tests/cases/libs/controller/components/auth.test.php b/lib/Cake/tests/cases/libs/controller/components/auth.test.php index e894e32ea..dbc939990 100644 --- a/lib/Cake/tests/cases/libs/controller/components/auth.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/auth.test.php @@ -148,6 +148,15 @@ class AuthTestController extends Controller { function admin_login() { } +/** + * admin_add method + * + * @access public + * @return void + */ + function admin_add() { + } + /** * logout method * @@ -917,6 +926,7 @@ class AuthTest extends CakeTestCase { $this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->query['url'] = ltrim($url, '/'); $this->Auth->request->base = ''; + Router::setRequestInfo($this->Auth->request); $this->Auth->initialize($this->Controller); diff --git a/lib/Cake/tests/cases/libs/dispatcher.test.php b/lib/Cake/tests/cases/libs/dispatcher.test.php index b3f12d974..fadf9b6b3 100644 --- a/lib/Cake/tests/cases/libs/dispatcher.test.php +++ b/lib/Cake/tests/cases/libs/dispatcher.test.php @@ -59,15 +59,6 @@ class TestDispatcher extends Dispatcher { return $controller; } -/** - * _stop method - * - * @return void - */ - protected function _stop() { - $this->stopped = true; - return true; - } } /** @@ -1356,9 +1347,8 @@ class DispatcherTest extends CakeTestCase { )); ob_start(); - $Dispatcher->asset('ccss/cake.generic.css'); + $this->assertTrue($Dispatcher->asset('ccss/cake.generic.css')); $result = ob_get_clean(); - $this->assertTrue($Dispatcher->stopped); } /** @@ -1373,28 +1363,17 @@ class DispatcherTest extends CakeTestCase { 'js' => '', 'css' => '' )); - $Dispatcher->asset('theme/test_theme/ccss/cake.generic.css'); - $this->assertTrue($Dispatcher->stopped); + $this->assertTrue($Dispatcher->asset('theme/test_theme/ccss/cake.generic.css')); - $Dispatcher->stopped = false; - $Dispatcher->asset('theme/test_theme/cjs/debug_kit.js'); - $this->assertTrue($Dispatcher->stopped); + $this->assertTrue($Dispatcher->asset('theme/test_theme/cjs/debug_kit.js')); - $Dispatcher->stopped = false; - $Dispatcher->asset('test_plugin/ccss/cake.generic.css'); - $this->assertTrue($Dispatcher->stopped); + $this->assertTrue($Dispatcher->asset('test_plugin/ccss/cake.generic.css')); - $Dispatcher->stopped = false; - $Dispatcher->asset('test_plugin/cjs/debug_kit.js'); - $this->assertTrue($Dispatcher->stopped); + $this->assertTrue($Dispatcher->asset('test_plugin/cjs/debug_kit.js')); - $Dispatcher->stopped = false; - $Dispatcher->asset('css/ccss/debug_kit.css'); - $this->assertFalse($Dispatcher->stopped); + $this->assertFalse($Dispatcher->asset('css/ccss/debug_kit.css')); - $Dispatcher->stopped = false; - $Dispatcher->asset('js/cjs/debug_kit.js'); - $this->assertFalse($Dispatcher->stopped); + $this->assertFalse($Dispatcher->asset('js/cjs/debug_kit.js')); } /** * testFullPageCachingDispatch method diff --git a/lib/Cake/tests/cases/libs/error/exception_renderer.test.php b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php index 765706be1..950caba78 100644 --- a/lib/Cake/tests/cases/libs/error/exception_renderer.test.php +++ b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php @@ -360,7 +360,7 @@ class ExceptionRendererTest extends CakeTestCase { $result = ob_get_clean(); $this->assertPattern('/

Custom message<\/h2>/', $result); - $this->assertPattern("/'\/posts\/view\/1000'<\/strong>/", $result); + $this->assertPattern("/'.*?\/posts\/view\/1000'<\/strong>/", $result); } /** diff --git a/lib/Cake/tests/cases/libs/router.test.php b/lib/Cake/tests/cases/libs/router.test.php index 7fb4bb650..ac6f2fda6 100644 --- a/lib/Cake/tests/cases/libs/router.test.php +++ b/lib/Cake/tests/cases/libs/router.test.php @@ -1878,7 +1878,7 @@ class RouterTest extends CakeTestCase { ); $result = Router::parse('/admin/posts/'); - $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'admin', 'plugin' => null, 'controller' => 'posts', 'action' => 'index', 'admin' => true); + $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'admin', 'plugin' => null, 'controller' => 'posts', 'action' => 'admin_index', 'admin' => true); $this->assertEqual($result, $expected); $result = Router::parse('/admin/posts'); @@ -1912,7 +1912,7 @@ class RouterTest extends CakeTestCase { ); $result = Router::parse('/members/posts/index'); - $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'members', 'plugin' => null, 'controller' => 'posts', 'action' => 'index', 'members' => true); + $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'members', 'plugin' => null, 'controller' => 'posts', 'action' => 'members_index', 'members' => true); $this->assertEqual($result, $expected); $result = Router::url(array('members' => true, 'controller' => 'posts', 'action' =>'index', 'page' => 2)); @@ -1942,6 +1942,10 @@ class RouterTest extends CakeTestCase { $expected = '/company/users/login'; $this->assertEqual($result, $expected); + $result = Router::url(array('controller' => 'users', 'action' => 'company_login', 'company' => true)); + $expected = '/company/users/login'; + $this->assertEqual($result, $expected); + $request = new CakeRequest(); Router::setRequestInfo( $request->addParams(array(