Permalink
Browse files

View::get() to support a fallback param

  • Loading branch information...
1 parent c27aa99 commit 0c3197a435ee319ac78a6f7dff8255f0abc7892c @sime sime committed Sep 11, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/Cake/View/View.php
View
@@ -582,11 +582,12 @@ public function getVar($var) {
* 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];
}

0 comments on commit 0c3197a

Please sign in to comment.