mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Allowed the use of empty() and isset() in Controllers aliases properties.
This commit is contained in:
parent
e9851a644b
commit
7f448a1d35
2 changed files with 23 additions and 0 deletions
|
@ -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.
|
||||||
|
|
|
@ -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']);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue