From e4b2fb173bc665fda2b46dc3808c74f62ebf14d6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 10 Sep 2010 23:55:42 -0400 Subject: [PATCH] Removing the deprecated properties. Removing property copying to helpers. Making the view test cases pass again. --- cake/libs/controller/controller.php | 2 +- cake/libs/view/helper_collection.php | 2 +- cake/libs/view/view.php | 71 +++++++++--------------- cake/tests/cases/libs/view/view.test.php | 7 +-- 4 files changed, 30 insertions(+), 52 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 57fcfeeac..0b2e55c35 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -341,7 +341,7 @@ class Controller extends Object { 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; } diff --git a/cake/libs/view/helper_collection.php b/cake/libs/view/helper_collection.php index faa63b14a..27f9d00bb 100644 --- a/cake/libs/view/helper_collection.php +++ b/cake/libs/view/helper_collection.php @@ -68,7 +68,7 @@ class HelperCollection extends ObjectCollection { } $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}; } diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 741d6d461..0876238aa 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -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. * @@ -73,21 +58,6 @@ 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 * @@ -95,13 +65,6 @@ class View extends Object { */ public $passedArgs = array(); -/** - * Array of data - * - * @var array Parameter data - */ - public $data = array(); - /** * An array of names of built-in helpers to include. * @@ -269,6 +232,15 @@ 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 * @@ -276,9 +248,8 @@ class View extends Object { * @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' ); /** @@ -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) { 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; } @@ -712,10 +691,10 @@ class View extends Object { 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; diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 8faf32dee..2466f5228 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -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 @@ -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();