コード例 #1
0
 /**
  * Supports a simple form of Fluent Interfaces. Allows you to 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.
  *
  * For example : $view->layout('foo')->title('name')->display().
  *
  * @param   string  Method name
  * @param   array   Array containing all the arguments for the original call
  * @return  KViewAbstract
  *
  * @see http://martinfowler.com/bliki/FluentInterface.html
  */
 public function __call($method, $args)
 {
     //If one argument is passed we assume a setter method is being called
     if (count($args) == 1) {
         if (method_exists($this, 'set' . ucfirst($method))) {
             return $this->{'set' . ucfirst($method)}($args[0]);
         } else {
             return $this->set($method, $args[0]);
         }
     }
     return parent::__call($method, $args);
 }