Skip to content

Commit

Permalink
Allowed the use of empty() and isset() in Controllers aliases propert…
Browse files Browse the repository at this point in the history
…ies.
  • Loading branch information
jrbasso committed Nov 1, 2010
1 parent e9851a6 commit 7f448a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cake/libs/controller/controller.php
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions cake/tests/cases/libs/controller/controller.test.php
Expand Up @@ -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']);
}
Expand Down

0 comments on commit 7f448a1

Please sign in to comment.