Adding BC wrappers for helpers.

Updating paginator test case to use non deprecated properties.
This commit is contained in:
mark_story 2010-09-12 00:24:37 -04:00
parent 003d02d8d9
commit 2906927a16
2 changed files with 32 additions and 51 deletions

View file

@ -47,22 +47,6 @@ class Helper extends Object {
*/
protected $_helperMap = array();
/**
* Base URL
*
* @deprecated use $request->base instead
* @var string
*/
public $base = null;
/**
* Webroot path
*
* @deprecated use $request->webroot instead
* @var string
*/
public $webroot = null;
/**
* The current theme name if any.
*
@ -70,22 +54,6 @@ class Helper extends Object {
*/
public $theme = null;
/**
* URL to current action.
*
* @deprecated use $request->here instead
* @var string
*/
public $here = null;
/**
* Parameter array.
*
* @deprecated use $request instead
* @var array
*/
public $params = array();
/**
* Request object
*
@ -93,14 +61,6 @@ class Helper extends Object {
*/
public $request = null;
/**
* Current action.
*
* @deprecated use $request->action instead
* @var string
*/
public $action = null;
/**
* Plugin path
*
@ -108,14 +68,6 @@ class Helper extends Object {
*/
public $plugin = null;
/**
* POST data for models
*
* @deprecated use $request->data instead
* @var array
*/
public $data = null;
/**
* Contains model validation errors of form post-backs
*
@ -181,7 +133,7 @@ class Helper extends Object {
}
/**
* Lazy loads helpers
* Lazy loads helpers. Provides access to deprecated request properties as well.
*
* @param string $name Name of the property being accessed.
* @return mixed Helper or property found at $name
@ -195,6 +147,35 @@ class Helper extends Object {
if (isset($this->{$name})) {
return $this->{$name};
}
switch ($name) {
case 'base':
case 'here':
case 'webroot':
case 'data':
return $this->request->{$name};
case 'action':
return isset($this->request->params['action']) ? $this->request->params['action'] : '';
case 'params':
return $this->request;
}
}
/**
* Provides backwards compatiblity access for setting values to the request object.
*
* @return void
*/
public function __set($name, $value) {
switch ($name) {
case 'base':
case 'here':
case 'webroot':
case 'data':
return $this->request->{$name} = $value;
case 'action':
return $this->request->params['action'] = $value;
}
return $this->{$name} = $value;
}
/**

View file

@ -212,8 +212,8 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('Title', 'title', array('direction' => 'desc'));
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('Title', 'title', array('direction' => 'desc', 'class' => 'foo'));
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="foo asc">Title<\/a>$/', $result);
}