Skip to content
Permalink
Browse files

Allowed the use of empty() and isset() in Controllers aliases propert…

…ies.
  • Loading branch information...
jrbasso committed Nov 1, 2010
1 parent e9851a6 commit 7f448a1d35f89822c1da538dfc9c24539ce4aaab
Showing with 23 additions and 0 deletions.
  1. +18 −0 cake/libs/controller/controller.php
  2. +5 −0 cake/tests/cases/libs/controller/controller.test.php
@@ -327,6 +327,24 @@ public function __construct($request = null) {
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.
* Also provides the params alias.
@@ -1543,6 +1543,11 @@ function testPropertyBackwardsCompatibility() {
$this->assertEquals($request->here, $Controller->here);
$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->params['controller'], $Controller->params['controller']);
}

0 comments on commit 7f448a1

Please sign in to comment.
You can’t perform that action at this time.