Skip to content

Commit

Permalink
Removing the deprecated properties.
Browse files Browse the repository at this point in the history
Removing property copying to helpers.
Making the view test cases pass again.
  • Loading branch information
markstory committed Sep 14, 2010
1 parent 634cea2 commit e4b2fb1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 52 deletions.
2 changes: 1 addition & 1 deletion cake/libs/controller/controller.php
Expand Up @@ -341,7 +341,7 @@ public function __get($name) {
case 'data':
return $this->request->{$name};
case 'action':
return $this->request->params['action'];
return isset($this->request->params['action']) ? $this->request->params['action'] : '';
case 'params':
return $this->request;
}
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helper_collection.php
Expand Up @@ -68,7 +68,7 @@ public function load($helper, $settings = array(), $enable = true) {
}
$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) {
$this->_loaded[$name]->{$var} = $this->_View->{$var};
}
Expand Down
71 changes: 25 additions & 46 deletions cake/libs/view/view.php
Expand Up @@ -42,21 +42,6 @@ class View extends Object {
*/
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.
*
Expand All @@ -73,35 +58,13 @@ class View extends Object {
*/
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
*
* @var mixed
*/
public $passedArgs = array();

/**
* Array of data
*
* @var array Parameter data
*/
public $data = array();

/**
* An array of names of built-in helpers to include.
*
Expand Down Expand Up @@ -269,16 +232,24 @@ class View extends Object {
*/
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
*
* @var array
* @access protected
*/
private $__passedVars = array(
'viewVars', 'autoLayout', 'autoRender', 'ext', 'base', 'webroot',
'helpers', 'here', 'layout', 'name', 'layoutPath', 'viewPath',
'params', 'request', 'data', 'plugin', 'passedArgs', 'cacheAction'
'viewVars', 'autoLayout', 'autoRender', 'ext', 'helpers', 'layout', 'name',
'layoutPath', 'viewPath', 'request', 'plugin', 'passedArgs', 'cacheAction'
);

/**
Expand Down Expand Up @@ -645,17 +616,25 @@ public function error($code, $name, $message) {
}

/**
* 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) {
if (isset($this->Helpers->{$name})) {
return $this->Helpers->{$name};
}
switch ($name) {
case 'base':
case 'here':
case 'webroot':
case 'data':
return $this->request->{$name};
case 'action':
return $this->request->params['action'];
return isset($this->request->params['action']) ? $this->request->params['action'] : '';
case 'params':
return $this->request;
}
return null;
}
Expand Down Expand Up @@ -712,10 +691,10 @@ protected function _render($___viewFn, $___dataForView, $loadHelpers = true, $ca
if ($caching) {
if (isset($this->Helpers->Cache)) {
$cache =& $this->Helpers->Cache;
$cache->base = $this->base;
$cache->here = $this->here;
$cache->base = $this->request->base;
$cache->here = $this->request->here;
$cache->helpers = $this->helpers;
$cache->action = $this->action;
$cache->action = $this->request->action;
$cache->controllerName = $this->name;
$cache->layout = $this->layout;
$cache->cacheAction = $this->cacheAction;
Expand Down
7 changes: 3 additions & 4 deletions cake/tests/cases/libs/view/view.test.php
Expand Up @@ -19,10 +19,8 @@
*/
App::import('Core', array('View', 'Controller'));
App::import('Helper', 'Cache');
App::import('Core', array('ErrorHandler'));

if (!class_exists('ErrorHandler')) {
App::import('Core', array('Error'));
}

/**
* ViewPostsController class
Expand Down Expand Up @@ -227,8 +225,9 @@ class ViewTest extends CakeTestCase {
*/
function setUp() {
Router::reload();
$this->Controller = new Controller();

$request = $this->getMock('CakeRequest');
$this->Controller = new Controller($request);
$this->PostsController = new ViewPostsController($request);
$this->PostsController->viewPath = 'posts';
$this->PostsController->index();
Expand Down

0 comments on commit e4b2fb1

Please sign in to comment.