public function do_functions() { $use = !$this->form->_validated ? 'on_failure' : 'on_success'; foreach ($this->{$use} as $array) { list($function, $args) = Formo::into_function($array['function']); if ($array['args']) { array_unshift($args, $array['args']); } array_unshift($args, $this->form->get_values()); switch ($function) { case 'url::redirect': url::redirect($args[count($args) - 1]); break; default: call_user_func_array($function, $args); return; } } }
protected function _do_rule($rule) { $rule = (is_array($rule) and isset($rule['rule'])) ? $rule['rule'] : $rule; $form_level_rules = array('match', 'depends_on'); if (isset($rule[0]) and is_object($rule[0])) { return call_user_func($rule, $this->value); } list($function, $args) = Formo::into_function($rule); if ($function == 'matches' or $function == 'depends_on') { $values = array(); foreach ($args as $match) { if (is_array($match)) { foreach ($match as $match_val) { $values[$match_val] = Input::instance()->post($match_val); } } else { $values[$match] = Input::instance()->post($match); } } return Formo::$function($this->value, $values); } if (preg_match('/::/', $function)) { array_unshift($args, $this->value); return call_user_func_array($function, $args); } elseif (method_exists('valid', $function)) { array_unshift($args, $this->value); return call_user_func_array('valid::' . $function, $args); } elseif (method_exists('Validation', $function)) { $use_args = !isset($args[0]) ? array() : $args[0]; $use_args = !is_array($args[0]) ? array($use_args) : $use_args; return Validation::$function($this->value, $use_args); } elseif (!in_array($function, $form_level_rules)) { array_unshift($args, $this->value); return call_user_func_array($function, $args); } }