Ejemplo n.º 1
0
 /**
  * Supports a simple form Fluent Interfaces. Allows you to set the request properties by using the request property
  * name as the method name.
  *
  * For example : $controller->limit(10)->browse();
  *
  * @param   string  $method Method name
  * @param   array   $args   Array containing all the arguments for the original call
  * @return  KControllerModel
  *
  * @see http://martinfowler.com/bliki/FluentInterface.html
  */
 public function __call($method, $args)
 {
     //Handle action alias method
     if (in_array($method, $this->getActions())) {
         //Get the data
         $data = !empty($args) ? $args[0] : array();
         //Set the data in the request
         if (!$data instanceof KCommandInterface) {
             //Make sure the data is cleared on HMVC calls
             $this->getRequest()->getData()->clear();
             //Automatic set the data in the request if an associative array is passed
             if (is_array($data) && !is_numeric(key($data))) {
                 $this->getRequest()->getData()->add($data);
             }
         }
     }
     //Check first if we are calling a mixed in method to prevent the model being
     //loaded during object instantiation.
     if (!isset($this->_mixed_methods[$method])) {
         //Check for model state properties
         if (isset($this->getModel()->getState()->{$method})) {
             $this->getRequest()->getQuery()->set($method, $args[0]);
             $this->getModel()->getState()->set($method, $args[0]);
             return $this;
         }
     }
     return parent::__call($method, $args);
 }
Ejemplo n.º 2
0
 /**
  * Supports a simple form Fluent Interfaces. Allows you to set the request 
  * properties by using the request property name as the method name.
  *
  * For example : $controller->view('name')->limit(10)->browse();
  *
  * @param	string	Method name
  * @param	array	Array containing all the arguments for the original call
  * @return	KControllerBread
  *
  * @see http://martinfowler.com/bliki/FluentInterface.html
  */
 public function __call($method, $args)
 {
     //Check first if we are calling a mixed in method. This prevents the model being
     //loaded durig object instantiation.
     if (!isset($this->_mixed_methods[$method])) {
         //Check if the method is a state property
         $state = $this->getModel()->getState();
         if (isset($state->{$method})) {
             $this->{$method} = $args[0];
             return $this;
         }
     }
     return parent::__call($method, $args);
 }