Merge remote branch 'origin/2.0' into 2.0-class-loading

This commit is contained in:
José Lorenzo Rodríguez 2010-12-19 23:12:37 -04:30
commit 827a74b734
17 changed files with 56 additions and 63 deletions

View file

@ -113,13 +113,13 @@ class PaginatorControllerPost extends CakeTestModel {
* @access public
* @return void
*/
function find($type, $options = array()) {
if ($type == 'popular') {
function find($conditions = null, $fields = array(), $order = null, $recursive = null) {
if ($conditions == 'popular') {
$conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1');
$options = Set::merge($options, compact('conditions'));
$options = Set::merge($fields, compact('conditions'));
return parent::find('all', $options);
}
return parent::find($type, $options);
return parent::find($conditions, $fields);
}
}

View file

@ -108,7 +108,7 @@ class Component extends Object {
* @return void
* @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components
*/
public function initialize(&$controller) { }
public function initialize($controller) { }
/**
* Called after the Controller::beforeFilter() and before the controller action
@ -117,7 +117,7 @@ class Component extends Object {
* @return void
* @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components
*/
public function startup(&$controller) { }
public function startup($controller) { }
/**
* Called after the Controller::beforeRender(), after the view class is loaded, and before the
@ -126,7 +126,7 @@ class Component extends Object {
* @param object $controller Controller with components to beforeRender
* @return void
*/
public function beforeRender(&$controller) { }
public function beforeRender($controller) { }
/**
* Called after Controller::render() and before the output is printed to the browser.
@ -134,7 +134,7 @@ class Component extends Object {
* @param object $controller Controller with components to shutdown
* @return void
*/
function shutdown(&$controller) { }
function shutdown($controller) { }
/**
* Called before Controller::redirect(). Allows you to replace the url that will
@ -154,6 +154,6 @@ class Component extends Object {
* @param bool $exit Will the script exit.
* @return mixed Either an array or null.
*/
public function beforeRedirect(&$controller, $url, $status = null, $exit = true) {}
public function beforeRedirect($controller, $url, $status = null, $exit = true) {}
}

View file

@ -263,7 +263,7 @@ class AuthComponent extends Component {
* @param object $controller A reference to the instantiating controller object
* @return void
*/
public function initialize(Controller $controller, $settings = array()) {
public function initialize($controller) {
$this->request = $controller->request;
$this->params = $this->request;
@ -299,7 +299,7 @@ class AuthComponent extends Component {
* @param object $controller A reference to the instantiating controller object
* @return boolean
*/
public function startup(&$controller) {
public function startup($controller) {
$isErrorOrTests = (
strtolower($controller->name) == 'cakeerror' ||
(strtolower($controller->name) == 'tests' && Configure::read('debug') > 0)
@ -926,7 +926,7 @@ class AuthComponent extends Component {
*
* @param object $controller Instantiating controller
*/
public function shutdown(&$controller) {
public function shutdown($controller) {
if ($this->_loggedIn) {
$this->Session->delete('Auth.redirect');
}

View file

@ -182,7 +182,7 @@ class CookieComponent extends Component {
* Start CookieComponent for use in the controller
*
*/
public function startup() {
public function startup($controller) {
$this->_expire($this->time);
if (isset($_COOKIE[$this->name])) {

View file

@ -338,7 +338,7 @@ class EmailComponent extends Component {
*
* @param object $controller Instantiating controller
*/
public function initialize(&$controller) {
public function initialize($controller) {
if (Configure::read('App.encoding') !== null) {
$this->charset = Configure::read('App.encoding');
}
@ -349,7 +349,7 @@ class EmailComponent extends Component {
*
* @param object $controller Instantiating controller
*/
public function startup(&$controller) {}
public function startup($controller) {}
/**
* Send an email using the specified content, template and layout

View file

@ -120,7 +120,7 @@ class RequestHandlerComponent extends Component {
* @return void
* @see Router::parseExtensions()
*/
public function initialize(&$controller, $settings = array()) {
public function initialize($controller, $settings = array()) {
$this->request = $controller->request;
$this->response = $controller->response;
if (isset($this->request->params['url']['ext'])) {
@ -158,7 +158,7 @@ class RequestHandlerComponent extends Component {
* @param object $controller A reference to the controller
* @return void
*/
public function startup(&$controller) {
public function startup($controller) {
$controller->request->params['isAjax'] = $this->request->is('ajax');
$isRecognized = (
!in_array($this->ext, array('html', 'htm')) &&
@ -193,7 +193,7 @@ class RequestHandlerComponent extends Component {
* @param mixed $url A string or array containing the redirect location
* @param mixed HTTP Status for redirect
*/
public function beforeRedirect(&$controller, $url, $status = null) {
public function beforeRedirect($controller, $url, $status = null, $exit = true) {
if (!$this->request->is('ajax')) {
return;
}
@ -508,7 +508,7 @@ class RequestHandlerComponent extends Component {
* @see RequestHandlerComponent::setContent()
* @see RequestHandlerComponent::respondAs()
*/
public function renderAs(&$controller, $type, $options = array()) {
public function renderAs($controller, $type, $options = array()) {
$defaults = array('charset' => 'UTF-8');
if (Configure::read('App.encoding') !== null) {

View file

@ -211,7 +211,7 @@ class SecurityComponent extends Component {
* @param object $controller Instantiating controller
* @return void
*/
public function startup(&$controller) {
public function startup($controller) {
$this->request = $controller->request;
$this->_action = strtolower($this->request->params['action']);
$this->_methodsRequired($controller);
@ -441,7 +441,7 @@ class SecurityComponent extends Component {
* @see SecurityComponent::$blackHoleCallback
* @link http://book.cakephp.org/view/1307/blackHole-object-controller-string-error
*/
function blackHole(&$controller, $error = '') {
function blackHole($controller, $error = '') {
if ($this->blackHoleCallback == null) {
$code = 404;
if ($error == 'login') {
@ -474,7 +474,7 @@ class SecurityComponent extends Component {
* @param object $controller Instantiating controller
* @return bool true if $method is required
*/
protected function _methodsRequired(&$controller) {
protected function _methodsRequired($controller) {
foreach (array('Post', 'Get', 'Put', 'Delete') as $method) {
$property = 'require' . $method;
if (is_array($this->$property) && !empty($this->$property)) {
@ -497,7 +497,7 @@ class SecurityComponent extends Component {
* @param object $controller Instantiating controller
* @return bool true if secure connection required
*/
protected function _secureRequired(&$controller) {
protected function _secureRequired($controller) {
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
$requireSecure = array_map('strtolower', $this->requireSecure);
@ -518,7 +518,7 @@ class SecurityComponent extends Component {
* @param object $controller Instantiating controller
* @return bool true if authentication required
*/
protected function _authRequired(&$controller) {
protected function _authRequired($controller) {
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) {
$requireAuth = array_map('strtolower', $this->requireAuth);
@ -553,7 +553,7 @@ class SecurityComponent extends Component {
* @param object $controller Instantiating controller
* @return bool true if login is required
*/
protected function _loginRequired(&$controller) {
protected function _loginRequired($controller) {
if (is_array($this->requireLogin) && !empty($this->requireLogin)) {
$requireLogin = array_map('strtolower', $this->requireLogin);
@ -600,7 +600,7 @@ class SecurityComponent extends Component {
* @param object $controller Instantiating controller
* @return bool true if submitted form is valid
*/
protected function _validatePost(&$controller) {
protected function _validatePost($controller) {
if (empty($controller->request->data)) {
return true;
}
@ -672,7 +672,7 @@ class SecurityComponent extends Component {
* @param object $controller Instantiating controller
* @return bool Success
*/
protected function _generateToken(&$controller) {
protected function _generateToken($controller) {
if (isset($controller->request->params['requested']) && $controller->request->params['requested'] === 1) {
if ($this->Session->check('_Token')) {
$tokenData = $this->Session->read('_Token');
@ -765,7 +765,7 @@ class SecurityComponent extends Component {
* @param array $params Parameters to send to method
* @return mixed Controller callback method's response
*/
protected function _callback(&$controller, $method, $params = array()) {
protected function _callback($controller, $method, $params = array()) {
if (is_callable(array($controller, $method))) {
return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params);
} else {

View file

@ -1217,7 +1217,8 @@ class Router {
} else {
if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) {
$matches = array_reverse($matches);
$key = array_shift(explode('[', $key));
$parts = explode('[', $key);
$key = array_shift($parts);
$arr = $val;
foreach ($matches as $match) {
if (empty($match[1])) {

View file

@ -53,7 +53,7 @@ class ParamTestComponent extends Component {
* @access public
* @return void
*/
function initialize(&$controller, $settings) {
function initialize($controllerz) {
foreach ($settings as $key => $value) {
if (is_numeric($key)) {
$this->{$value} = true;
@ -121,7 +121,7 @@ class AppleComponent extends Component {
* @access public
* @return void
*/
function startup(&$controller) {
function startup($controller) {
$this->testName = $controller->name;
}
}
@ -149,7 +149,7 @@ class OrangeComponent extends Component {
* @access public
* @return void
*/
function initialize(&$controller) {
function initialize($controller) {
$this->Controller = $controller;
$this->Banana->testField = 'OrangeField';
}
@ -160,7 +160,7 @@ class OrangeComponent extends Component {
* @param Controller $controller
* @return string
*/
public function startup(&$controller) {
public function startup($controller) {
$controller->foo = 'pass';
}
}
@ -187,7 +187,7 @@ class BananaComponent extends Component {
* @param Controller $controller
* @return string
*/
public function startup(&$controller) {
public function startup($controller) {
$controller->bar = 'fail';
}
}

View file

@ -53,7 +53,7 @@ class TestAuthComponent extends AuthComponent {
* @access public
* @return void
*/
function _stop() {
function _stop($status = 0) {
$this->testStop = true;
}
}
@ -499,7 +499,8 @@ class AuthTest extends CakeTestCase {
);
$this->Controller->beforeFilter();
ClassRegistry::addObject('view', new View($this->Controller));
$view = new View($this->Controller);
ClassRegistry::addObject('view', $view);
$this->Controller->Session->delete('Auth');
$this->Controller->Session->delete('Message.auth');

View file

@ -386,7 +386,7 @@ class CookieComponentTest extends CakeTestCase {
'name' => 'CakePHP',
'version' => '1.2.0.x',
'tag' => 'CakePHP Rocks!'));
$this->Cookie->startup();
$this->Cookie->startup(null);
$data = $this->Cookie->read('Encrytped_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');

View file

@ -230,7 +230,8 @@ class EmailComponentTest extends CakeTestCase {
$this->Controller->Components->init($this->Controller);
$this->Controller->EmailTest->initialize($this->Controller, array());
ClassRegistry::addObject('view', new View($this->Controller));
$view = new View($this->Controller);
ClassRegistry::addObject('view', $view);
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)

View file

@ -34,7 +34,7 @@ class TestSecurityComponent extends SecurityComponent {
* @param Controller $controller
* @return unknown
*/
function validatePost(&$controller) {
function validatePost($controller) {
return $this->_validatePost($controller);
}
}
@ -98,8 +98,8 @@ class SecurityTestController extends Controller {
* @access public
* @return void
*/
function redirect($option, $code, $exit) {
return $code;
function redirect($url, $status = null, $exit = true) {
return $status;
}
/**

View file

@ -107,13 +107,13 @@ class ControllerPost extends CakeTestModel {
* @access public
* @return void
*/
function find($type, $options = array()) {
if ($type == 'popular') {
function find($conditions = null, $fields = array(), $order = null, $recursive = null) {
if ($conditions == 'popular') {
$conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1');
$options = Set::merge($options, compact('conditions'));
return parent::find('all', $options);
$options = Set::merge($fields, compact('conditions'));
return parent::find('all', $fields);
}
return parent::find($type, $options);
return parent::find($conditions, $fields);
}
}
@ -320,7 +320,7 @@ class TestComponent extends Object {
* @access public
* @return void
*/
function initialize(&$controller) {
function initialize($controller) {
}
/**
@ -329,7 +329,7 @@ class TestComponent extends Object {
* @access public
* @return void
*/
function startup(&$controller) {
function startup($controller) {
}
/**
* shutdown method
@ -337,14 +337,14 @@ class TestComponent extends Object {
* @access public
* @return void
*/
function shutdown(&$controller) {
function shutdown($controller) {
}
/**
* beforeRender callback
*
* @return void
*/
function beforeRender(&$controller) {
function beforeRender($controller) {
if ($this->viewclass) {
$controller->view = $this->viewclass;
}

View file

@ -28,16 +28,6 @@ App::uses('PagesController', 'Controller');
*/
class PagesControllerTest extends CakeTestCase {
/**
* endTest method
*
* @access public
* @return void
*/
function endTest() {
App::build();
}
/**
* testDisplay method
*

View file

@ -93,8 +93,8 @@ class TestScaffoldMock extends Scaffold {
*
* @param unknown_type $params
*/
function _scaffold($params) {
$this->_params = $params;
function _scaffold(CakeRequest $request) {
$this->_params = $request;
}
/**

View file

@ -69,7 +69,7 @@ class BlueberryComponent extends Component {
* @access public
* @return void
*/
function initialize(&$controller) {
function initialize($controller) {
$this->testName = 'BlueberryComponent';
}
}