Browse Source

Chainable set()

euromark 11 years ago
parent
commit
3f3a875355
1 changed files with 8 additions and 7 deletions
  1. 8 7
      src/View/ViewVarsTrait.php

+ 8 - 7
src/View/ViewVarsTrait.php

@@ -93,24 +93,25 @@ trait ViewVarsTrait {
 	}
 
 /**
- * Saves a variable for use inside a template.
+ * Saves a variable or an associative array of variables for use inside a template.
  *
  * @param string|array $name A string or an array of data.
- * @param string|array|null $val Value in case $name is a string (which then works as the key).
+ * @param string|array|null $value Value in case $name is a string (which then works as the key).
  *   Unused if $name is an associative array, otherwise serves as the values to $name's keys.
- * @return void
+ * @return $this
  */
-	public function set($name, $val = null) {
+	public function set($name, $value = null) {
 		if (is_array($name)) {
-			if (is_array($val)) {
-				$data = array_combine($name, $val);
+			if (is_array($value)) {
+				$data = array_combine($name, $value);
 			} else {
 				$data = $name;
 			}
 		} else {
-			$data = [$name => $val];
+			$data = [$name => $value];
 		}
 		$this->viewVars = $data + $this->viewVars;
+		return $this;
 	}
 
 /**