Allowed the use of empty() and isset() in Controllers aliases properties.

This commit is contained in:
Juan Basso 2010-10-31 22:02:26 -02:00
parent e9851a644b
commit 7f448a1d35
2 changed files with 23 additions and 0 deletions

View file

@ -327,6 +327,24 @@ class Controller extends Object {
parent::__construct(); parent::__construct();
} }
/**
* Provides backwards compatbility avoid problems with empty and isset to alias properties.
*
* @return void
*/
public function __isset($name) {
switch ($name) {
case 'base':
case 'here':
case 'webroot':
case 'data':
case 'action':
case 'params':
return true;
}
return false;
}
/** /**
* Provides backwards compatbility access to the request object properties. * Provides backwards compatbility access to the request object properties.
* Also provides the params alias. * Also provides the params alias.

View file

@ -1543,6 +1543,11 @@ class ControllerTest extends CakeTestCase {
$this->assertEquals($request->here, $Controller->here); $this->assertEquals($request->here, $Controller->here);
$this->assertEquals($request->action, $Controller->action); $this->assertEquals($request->action, $Controller->action);
$this->assertFalse(empty($Controller->data));
$this->assertTrue(isset($Controller->data));
$this->assertTrue(empty($Controller->something));
$this->assertFalse(isset($Controller->something));
$this->assertEquals($request, $Controller->params); $this->assertEquals($request, $Controller->params);
$this->assertEquals($request->params['controller'], $Controller->params['controller']); $this->assertEquals($request->params['controller'], $Controller->params['controller']);
} }