Removing the deprecated properties.

Removing property copying to helpers.
Making the view test cases pass again.
This commit is contained in:
mark_story 2010-09-10 23:55:42 -04:00
parent 634cea24eb
commit e4b2fb173b
4 changed files with 30 additions and 52 deletions

View file

@ -341,7 +341,7 @@ class Controller extends Object {
case 'data': case 'data':
return $this->request->{$name}; return $this->request->{$name};
case 'action': case 'action':
return $this->request->params['action']; return isset($this->request->params['action']) ? $this->request->params['action'] : '';
case 'params': case 'params':
return $this->request; return $this->request;
} }

View file

@ -68,7 +68,7 @@ class HelperCollection extends ObjectCollection {
} }
$this->_loaded[$name] = new $helperClass($this->_View, $settings); $this->_loaded[$name] = new $helperClass($this->_View, $settings);
$vars = array('request', 'base', 'webroot', 'here', 'params', 'action', 'data', 'theme', 'plugin'); $vars = array('request', 'theme', 'plugin');
foreach ($vars as $var) { foreach ($vars as $var) {
$this->_loaded[$name]->{$var} = $this->_View->{$var}; $this->_loaded[$name]->{$var} = $this->_View->{$var};
} }

View file

@ -42,21 +42,6 @@ class View extends Object {
*/ */
public $Helpers; public $Helpers;
/**
* Path parts for creating links in views.
*
* @var string Base URL
* @access public
*/
public $base = null;
/**
* Stores the current URL (for links etc.)
*
* @var string Current URL
*/
public $here = null;
/** /**
* Name of the plugin. * Name of the plugin.
* *
@ -73,21 +58,6 @@ class View extends Object {
*/ */
public $name = null; public $name = null;
/**
* Action to be performed.
*
* @var string Name of action
* @access public
*/
public $action = null;
/**
* Array of parameter data
*
* @var array Parameter data
*/
public $params = array();
/** /**
* Current passed params * Current passed params
* *
@ -95,13 +65,6 @@ class View extends Object {
*/ */
public $passedArgs = array(); public $passedArgs = array();
/**
* Array of data
*
* @var array Parameter data
*/
public $data = array();
/** /**
* An array of names of built-in helpers to include. * An array of names of built-in helpers to include.
* *
@ -269,6 +232,15 @@ class View extends Object {
*/ */
public $output = false; public $output = false;
/**
* An instance of a CakeRequest object that contains information about the current request.
* This object contains all the information about a request and several methods for reading
* additional information about the request.
*
* @var CakeRequest
*/
public $request;
/** /**
* List of variables to collect from the associated controller * List of variables to collect from the associated controller
* *
@ -276,9 +248,8 @@ class View extends Object {
* @access protected * @access protected
*/ */
private $__passedVars = array( private $__passedVars = array(
'viewVars', 'autoLayout', 'autoRender', 'ext', 'base', 'webroot', 'viewVars', 'autoLayout', 'autoRender', 'ext', 'helpers', 'layout', 'name',
'helpers', 'here', 'layout', 'name', 'layoutPath', 'viewPath', 'layoutPath', 'viewPath', 'request', 'plugin', 'passedArgs', 'cacheAction'
'params', 'request', 'data', 'plugin', 'passedArgs', 'cacheAction'
); );
/** /**
@ -645,17 +616,25 @@ class View extends Object {
} }
/** /**
* Magic accessor for helpers. * Magic accessor for helpers. Provides access to attributes that were deprecated.
* *
* @return void * @param string $name Name of the attribute to get.
* @return mixed
*/ */
public function __get($name) { public function __get($name) {
if (isset($this->Helpers->{$name})) { if (isset($this->Helpers->{$name})) {
return $this->Helpers->{$name}; return $this->Helpers->{$name};
} }
switch ($name) { switch ($name) {
case 'base':
case 'here':
case 'webroot':
case 'data':
return $this->request->{$name};
case 'action': case 'action':
return $this->request->params['action']; return isset($this->request->params['action']) ? $this->request->params['action'] : '';
case 'params':
return $this->request;
} }
return null; return null;
} }
@ -712,10 +691,10 @@ class View extends Object {
if ($caching) { if ($caching) {
if (isset($this->Helpers->Cache)) { if (isset($this->Helpers->Cache)) {
$cache =& $this->Helpers->Cache; $cache =& $this->Helpers->Cache;
$cache->base = $this->base; $cache->base = $this->request->base;
$cache->here = $this->here; $cache->here = $this->request->here;
$cache->helpers = $this->helpers; $cache->helpers = $this->helpers;
$cache->action = $this->action; $cache->action = $this->request->action;
$cache->controllerName = $this->name; $cache->controllerName = $this->name;
$cache->layout = $this->layout; $cache->layout = $this->layout;
$cache->cacheAction = $this->cacheAction; $cache->cacheAction = $this->cacheAction;

View file

@ -19,10 +19,8 @@
*/ */
App::import('Core', array('View', 'Controller')); App::import('Core', array('View', 'Controller'));
App::import('Helper', 'Cache'); App::import('Helper', 'Cache');
App::import('Core', array('ErrorHandler'));
if (!class_exists('ErrorHandler')) {
App::import('Core', array('Error'));
}
/** /**
* ViewPostsController class * ViewPostsController class
@ -227,8 +225,9 @@ class ViewTest extends CakeTestCase {
*/ */
function setUp() { function setUp() {
Router::reload(); Router::reload();
$this->Controller = new Controller();
$request = $this->getMock('CakeRequest'); $request = $this->getMock('CakeRequest');
$this->Controller = new Controller($request);
$this->PostsController = new ViewPostsController($request); $this->PostsController = new ViewPostsController($request);
$this->PostsController->viewPath = 'posts'; $this->PostsController->viewPath = 'posts';
$this->PostsController->index(); $this->PostsController->index();