mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-28 22:59:46 +00:00
Merge remote-tracking branch 'origin/2.0' into 2.0-class-loading
This commit is contained in:
commit
90b01b7ec3
10 changed files with 42 additions and 60 deletions
lib/Cake
Controller
Error
Routing
View
tests/cases/libs
|
@ -22,10 +22,8 @@ class CakeErrorController extends AppController {
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
function __construct($request = null) {
|
||||||
parent::__construct();
|
parent::__construct($request);
|
||||||
$this->_set(Router::getPaths());
|
|
||||||
$this->request = Router::getRequest(false);
|
|
||||||
$this->constructClasses();
|
$this->constructClasses();
|
||||||
$this->Components->trigger('initialize', array(&$this));
|
$this->Components->trigger('initialize', array(&$this));
|
||||||
$this->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
|
$this->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
|
||||||
|
|
|
@ -147,9 +147,9 @@ class ExceptionRenderer {
|
||||||
|
|
||||||
if ($__previousError != $exception) {
|
if ($__previousError != $exception) {
|
||||||
$__previousError = $exception;
|
$__previousError = $exception;
|
||||||
$controller = new CakeErrorController();
|
$controller = new CakeErrorController(Router::getRequest(false));
|
||||||
} else {
|
} else {
|
||||||
$controller = new Controller();
|
$controller = new Controller(Router::getRequest(false));
|
||||||
$controller->viewPath = 'errors';
|
$controller->viewPath = 'errors';
|
||||||
}
|
}
|
||||||
return $controller;
|
return $controller;
|
||||||
|
|
|
@ -40,14 +40,6 @@ App::uses('Debugger', 'Utility');
|
||||||
*/
|
*/
|
||||||
class Dispatcher {
|
class Dispatcher {
|
||||||
|
|
||||||
/**
|
|
||||||
* The request object
|
|
||||||
*
|
|
||||||
* @var CakeRequest
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $request = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response object used for asset/cached responses.
|
* Response object used for asset/cached responses.
|
||||||
*
|
*
|
||||||
|
@ -90,18 +82,16 @@ class Dispatcher {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->request = $this->parseParams($request, $additionalParams);
|
$request = $this->parseParams($request, $additionalParams);
|
||||||
$controller = $this->_getController($this->request);
|
Router::setRequestInfo($request);
|
||||||
|
$controller = $this->_getController($request);
|
||||||
|
|
||||||
if (!is_object($controller)) {
|
if (!($controller instanceof Controller)) {
|
||||||
Router::setRequestInfo($request);
|
|
||||||
throw new MissingControllerException(array(
|
throw new MissingControllerException(array(
|
||||||
'controller' => Inflector::camelize($request->params['controller']) . 'Controller'
|
'controller' => Inflector::camelize($request->params['controller']) . 'Controller'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Router::setRequestInfo($request);
|
|
||||||
|
|
||||||
if ($this->_isPrivateAction($request)) {
|
if ($this->_isPrivateAction($request)) {
|
||||||
throw new PrivateActionException(array(
|
throw new PrivateActionException(array(
|
||||||
'controller' => Inflector::camelize($request->params['controller']) . "Controller",
|
'controller' => Inflector::camelize($request->params['controller']) . "Controller",
|
||||||
|
@ -123,10 +113,8 @@ class Dispatcher {
|
||||||
$privateAction = $request->params['action'][0] === '_';
|
$privateAction = $request->params['action'][0] === '_';
|
||||||
$prefixes = Router::prefixes();
|
$prefixes = Router::prefixes();
|
||||||
|
|
||||||
if (!empty($prefixes)) {
|
if (!$privateAction && !empty($prefixes)) {
|
||||||
if (isset($request->params['prefix'])) {
|
if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) {
|
||||||
$request->params['action'] = $request->params['prefix'] . '_' . $request->params['action'];
|
|
||||||
} elseif (strpos($request->params['action'], '_') > 0) {
|
|
||||||
list($prefix, $action) = explode('_', $request->params['action']);
|
list($prefix, $action) = explode('_', $request->params['action']);
|
||||||
$privateAction = in_array($prefix, $prefixes);
|
$privateAction = in_array($prefix, $prefixes);
|
||||||
}
|
}
|
||||||
|
@ -303,13 +291,13 @@ class Dispatcher {
|
||||||
if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) {
|
if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) {
|
||||||
$this->response->statusCode(404);
|
$this->response->statusCode(404);
|
||||||
$this->response->send();
|
$this->response->send();
|
||||||
return $this->_stop();
|
return true;
|
||||||
} elseif ($isCss) {
|
} elseif ($isCss) {
|
||||||
include WWW_ROOT . DS . $filters['css'];
|
include WWW_ROOT . DS . $filters['css'];
|
||||||
$this->_stop();
|
return true;
|
||||||
} elseif ($isJs) {
|
} elseif ($isJs) {
|
||||||
include WWW_ROOT . DS . $filters['js'];
|
include WWW_ROOT . DS . $filters['js'];
|
||||||
$this->_stop();
|
return true;
|
||||||
}
|
}
|
||||||
$controller = null;
|
$controller = null;
|
||||||
$pathSegments = explode('.', $url);
|
$pathSegments = explode('.', $url);
|
||||||
|
|
|
@ -503,6 +503,9 @@ class Router {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($out['prefix'])) {
|
||||||
|
$out['action'] = $out['prefix'] . '_' . $out['action'];
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($ext) && !isset($out['url']['ext'])) {
|
if (!empty($ext) && !isset($out['url']['ext'])) {
|
||||||
$out['url']['ext'] = $ext;
|
$out['url']['ext'] = $ext;
|
||||||
|
|
|
@ -39,7 +39,7 @@ App::uses('CakeRequest', 'Network');
|
||||||
* {{{
|
* {{{
|
||||||
* class ExampleController extends AppController {
|
* class ExampleController extends AppController {
|
||||||
* function download () {
|
* function download () {
|
||||||
* $this->view = 'Media';
|
* $this->viewClass = 'Media';
|
||||||
* $params = array(
|
* $params = array(
|
||||||
* 'id' => 'example.zip',
|
* 'id' => 'example.zip',
|
||||||
* 'name' => 'example',
|
* 'name' => 'example',
|
||||||
|
|
|
@ -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
|
* 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
|
* 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.
|
* in your Controller to use the ThemeView.
|
||||||
*
|
*
|
||||||
* Example of theme path with `$this->theme = 'super_hot';` Would be `app/views/themed/super_hot/posts`
|
* Example of theme path with `$this->theme = 'super_hot';` Would be `app/views/themed/super_hot/posts`
|
||||||
|
|
|
@ -148,6 +148,15 @@ class AuthTestController extends Controller {
|
||||||
function admin_login() {
|
function admin_login() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* admin_add method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function admin_add() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logout method
|
* logout method
|
||||||
*
|
*
|
||||||
|
@ -917,6 +926,7 @@ class AuthTest extends CakeTestCase {
|
||||||
$this->Auth->request->addParams(Router::parse($url));
|
$this->Auth->request->addParams(Router::parse($url));
|
||||||
$this->Auth->request->query['url'] = ltrim($url, '/');
|
$this->Auth->request->query['url'] = ltrim($url, '/');
|
||||||
$this->Auth->request->base = '';
|
$this->Auth->request->base = '';
|
||||||
|
|
||||||
Router::setRequestInfo($this->Auth->request);
|
Router::setRequestInfo($this->Auth->request);
|
||||||
$this->Auth->initialize($this->Controller);
|
$this->Auth->initialize($this->Controller);
|
||||||
|
|
||||||
|
|
|
@ -59,15 +59,6 @@ class TestDispatcher extends Dispatcher {
|
||||||
return $controller;
|
return $controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* _stop method
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function _stop() {
|
|
||||||
$this->stopped = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1356,9 +1347,8 @@ class DispatcherTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$Dispatcher->asset('ccss/cake.generic.css');
|
$this->assertTrue($Dispatcher->asset('ccss/cake.generic.css'));
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
$this->assertTrue($Dispatcher->stopped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1373,28 +1363,17 @@ class DispatcherTest extends CakeTestCase {
|
||||||
'js' => '',
|
'js' => '',
|
||||||
'css' => ''
|
'css' => ''
|
||||||
));
|
));
|
||||||
$Dispatcher->asset('theme/test_theme/ccss/cake.generic.css');
|
$this->assertTrue($Dispatcher->asset('theme/test_theme/ccss/cake.generic.css'));
|
||||||
$this->assertTrue($Dispatcher->stopped);
|
|
||||||
|
|
||||||
$Dispatcher->stopped = false;
|
$this->assertTrue($Dispatcher->asset('theme/test_theme/cjs/debug_kit.js'));
|
||||||
$Dispatcher->asset('theme/test_theme/cjs/debug_kit.js');
|
|
||||||
$this->assertTrue($Dispatcher->stopped);
|
|
||||||
|
|
||||||
$Dispatcher->stopped = false;
|
$this->assertTrue($Dispatcher->asset('test_plugin/ccss/cake.generic.css'));
|
||||||
$Dispatcher->asset('test_plugin/ccss/cake.generic.css');
|
|
||||||
$this->assertTrue($Dispatcher->stopped);
|
|
||||||
|
|
||||||
$Dispatcher->stopped = false;
|
$this->assertTrue($Dispatcher->asset('test_plugin/cjs/debug_kit.js'));
|
||||||
$Dispatcher->asset('test_plugin/cjs/debug_kit.js');
|
|
||||||
$this->assertTrue($Dispatcher->stopped);
|
|
||||||
|
|
||||||
$Dispatcher->stopped = false;
|
$this->assertFalse($Dispatcher->asset('css/ccss/debug_kit.css'));
|
||||||
$Dispatcher->asset('css/ccss/debug_kit.css');
|
|
||||||
$this->assertFalse($Dispatcher->stopped);
|
|
||||||
|
|
||||||
$Dispatcher->stopped = false;
|
$this->assertFalse($Dispatcher->asset('js/cjs/debug_kit.js'));
|
||||||
$Dispatcher->asset('js/cjs/debug_kit.js');
|
|
||||||
$this->assertFalse($Dispatcher->stopped);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testFullPageCachingDispatch method
|
* testFullPageCachingDispatch method
|
||||||
|
|
|
@ -360,7 +360,7 @@ class ExceptionRendererTest extends CakeTestCase {
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
|
|
||||||
$this->assertPattern('/<h2>Custom message<\/h2>/', $result);
|
$this->assertPattern('/<h2>Custom message<\/h2>/', $result);
|
||||||
$this->assertPattern("/<strong>'\/posts\/view\/1000'<\/strong>/", $result);
|
$this->assertPattern("/<strong>'.*?\/posts\/view\/1000'<\/strong>/", $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1878,7 +1878,7 @@ class RouterTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Router::parse('/admin/posts/');
|
$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);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = Router::parse('/admin/posts');
|
$result = Router::parse('/admin/posts');
|
||||||
|
@ -1912,7 +1912,7 @@ class RouterTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Router::parse('/members/posts/index');
|
$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);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = Router::url(array('members' => true, 'controller' => 'posts', 'action' =>'index', 'page' => 2));
|
$result = Router::url(array('members' => true, 'controller' => 'posts', 'action' =>'index', 'page' => 2));
|
||||||
|
@ -1942,6 +1942,10 @@ class RouterTest extends CakeTestCase {
|
||||||
$expected = '/company/users/login';
|
$expected = '/company/users/login';
|
||||||
$this->assertEqual($result, $expected);
|
$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();
|
$request = new CakeRequest();
|
||||||
Router::setRequestInfo(
|
Router::setRequestInfo(
|
||||||
$request->addParams(array(
|
$request->addParams(array(
|
||||||
|
|
Loading…
Add table
Reference in a new issue