From 0c3197a435ee319ac78a6f7dff8255f0abc7892c Mon Sep 17 00:00:00 2001 From: Simon Males Date: Wed, 11 Sep 2013 11:10:27 +0800 Subject: [PATCH] View::get() to support a fallback param --- lib/Cake/View/View.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index 79fd648fa..af3c6574b 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -582,11 +582,12 @@ class View extends Object { * Blocks are checked before view variables. * * @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. */ - public function get($var) { + public function get($var, $default = null) { if (!isset($this->viewVars[$var])) { - return null; + return $default; } return $this->viewVars[$var]; }