Changeset 2533

User picture

Author: Johan Janssens

(2010/09/03 20:38) Over 1 year ago

re #99 : Added supports for simple Fluent Interfaces. You can now assign variables to the view by using the variable name as the method name. If the method name is a setter method the setter will be called instead.

Affected files

Updated branches/99-toolbar/code/libraries/koowa/view/template.php Download diff

25322533
418
	{
418
	{
419
		return $this->loadTemplate();
419
		return $this->loadTemplate();
420
	}
420
	}
421
	
422
	/**
423
	 * Supports a simple form of Fluent Interfaces. Allows you to assign variables to the view 
424
	 * by using the variable name as the method name. If the function name is a setter function
425
	 * the setter will be called instead.
426
	 *
427
	 * For example : $view->layout('foo')->title('name')->display().
428
	 *
429
	 * @param	string	Method name
430
	 * @param	array	Array containing all the arguments for the original call
431
	 * @return	KViewAbstract
432
	 *
433
	 * @see http://martinfowler.com/bliki/FluentInterface.html
434
	 */
435
	public function __call($method, $args)
436
	{
437
		if(method_exists($this, 'set'.ucfirst($method))) {
438
			return $this->{'set'.ucfirst($method)}($args[0]);
439
		} else {
440
			return $this->set($method, $args[0]);
441
		}
442
		
443
		return $this;
444
	}
421
}
445
}