/** * Magic method to set states by calling a method named as the filter * @param string $name The name of the state to apply * @param array $args The list of arguments passed to the method */ public function __call($name, $args) { // Go for the states! if (!method_exists($this, $name)) { // if no arguments supplied, abort if (!isset($args[0])) { return $this; } // The state name to set is the method name $state = (string) $name; // $model->categories(array('value' => '123', 'mode' => 'AND')); if (is_array($args[0]) || is_object($args[0])) { $options = new JRegistry($args[0]); } else { // $model->element('id', $options); if (isset($args[1])) { // $model->element('id', $options); if (is_array($args[1]) || is_object($args[1])) { $options = new JRegistry($args[1]); } else { // $model->element('id', 'value'); $options = new JRegistry(); $options->set('value', $args[1]); $options->set('id', $args[0]); } } else { $options = new JRegistry(); // Just the value $options->set('value', $args[0]); } } $this->setState($state, $options); return $this; } // Normal method calling return parent::__call($name, $args); }