/** * 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 ControllerModel * * @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 CommandInterface) { //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 (!$this->isMixedMethod($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); }
/** * 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 ControllerView * * @see http://martinfowler.com/bliki/FluentInterface.html */ public function __call($method, $args) { //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()->query->set($method, $args[0]); $this->getModel()->getState()->set($method, $args[0]); return $this; } } return parent::__call($method, $args); }