/** * 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}) || in_array($method, array('layout', 'view', 'format'))) { $this->{$method} = $args[0]; if ($method == 'view') { $this->_view = $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->view('name')->layout('form')->display(); * * @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. if (!isset($this->_mixed_methods[$method])) { if (in_array($method, array('layout', 'view', 'format'))) { $this->{$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->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) { //omit anything that starts with underscore if (strpos($method, '_') === false) { if (count($args) == 1 && !isset($this->_mixed_methods[$method]) && !in_array($method, $this->getActions())) { $this->{KInflector::underscore($method)} = $args[0]; return $this; } } elseif (strpos($method, '_action') === 0) { //if the missing method is _action[Name] but //method exists, then that means the action //has been called on the object parent i.e. //parent::_action[Name] but since the parent is //not implementing the action it falls back to //__call. //we need to check if a behavior implement this //method if (method_exists($this, $method)) { $action = strtolower(substr($method, 7)); if (isset($this->_mixed_methods[$action])) { return $this->_mixed_methods[$action]->execute('action.' . $action, isset($args[0]) ? $args[0] : null); } else { //we need to throw this //because if it goes to parent::__call it will causes //infinite recursion throw new BadMethodCallException('Call to undefined method :' . $method); } } } 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->view('name')->layout('name')->format('html')->render(); * * @param string $method Method name * @param array $args Array containing all the arguments for the original call * @return KControllerView * * @see http://martinfowler.com/bliki/FluentInterface.html */ public function __call($method, $args) { if (!isset($this->_mixed_methods[$method])) { if (in_array($method, array('layout', 'view', 'format'))) { if ($method == 'view') { $this->setView($args[0]); } if ($method == 'format') { $this->getRequest()->setFormat($args[0]); } if ($method == 'layout') { $this->getRequest()->getQuery()->set($method, $args[0]); } return $this; } } return parent::__call($method, $args); }