mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
View::get() to support a fallback param
This commit is contained in:
parent
c27aa99af9
commit
0c3197a435
1 changed files with 3 additions and 2 deletions
|
@ -582,11 +582,12 @@ class View extends Object {
|
||||||
* Blocks are checked before view variables.
|
* Blocks are checked before view variables.
|
||||||
*
|
*
|
||||||
* @param string $var The view var you want the contents of.
|
* @param string $var The view var you want the contents of.
|
||||||
|
* @param mixed $default The default/fallback content of $var.
|
||||||
* @return mixed The content of the named var if its set, otherwise null.
|
* @return mixed The content of the named var if its set, otherwise null.
|
||||||
*/
|
*/
|
||||||
public function get($var) {
|
public function get($var, $default = null) {
|
||||||
if (!isset($this->viewVars[$var])) {
|
if (!isset($this->viewVars[$var])) {
|
||||||
return null;
|
return $default;
|
||||||
}
|
}
|
||||||
return $this->viewVars[$var];
|
return $this->viewVars[$var];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue