/** * Overload the CI's default method to support ajax, form and the interceptors */ function _remap($method, $args) { set_breadscrum(); // Setting the breadscrums if (!method_exists($this, $method)) { if (get_class($this) != 'Page') { $this->warn('The method of %s is not exists, change to index', $method); } array_unshift($args, $method); $method = 'index'; } // Checking for the interceptors $interceptors = $this->interceptor_support->getInterceptors($method); // For before interceptor $failed = false; foreach ($interceptors['before'] as $before) { if (!$before->intercept($method, $args)) { // If any before inteceptor thinks this execution should be fail, then fail it $failed = true; if (isset($before->error_message)) { $this->error('Failed to pass the %s when calling method %s of %s of error message %s with args', $args, $before->toString(), $method, get_class($this), $before->error_message); trigger_error($before->error_message); } else { $this->error('Failed to pass the %s when calling method %s of %s of with args', $args, $before->toString(), $method, get_class($this)); } break; } } if ($failed) { return false; } // For around interceptor if (count($interceptors['around']) > 0) { $around = $interceptors['around'][0]; if (count($interceptors['around']) > 1) { $this->warn('The around interceptor for method %s is bigger than 1', $args, $method); } return $around->intercept($method, $args); } // Run the original method $ret = $this->_process($method, $args); // Run the after method foreach ($interceptors['after'] as $after) { $after->intercept($method, $args); } return $ret; }
/** * Overload the CI's default method to support ajax, form and the interceptors */ function _remap($method, $args) { $this->processAutoload(); set_breadscrum(); // Setting the breadscrums $method = $this->_get_method($method, $args); // Checking for the interceptors $interceptors = $this->interceptor_support->getInterceptors($method); $this->interceptors = $interceptors; // Save the interceptors for render to use // For before interceptor $failed = false; foreach ($interceptors['before'] as $before) { if (!$before->intercept($method, $args)) { // If any before inteceptor thinks this execution should be fail, then fail it $failed = true; if (isset($before->error_message)) { $this->error('Failed to pass the %s when calling method %s of %s of error message %s with args', $args, $before->toString(), $method, get_class($this), $before->error_message); trigger_error($before->error_message); } else { $this->error('Failed to pass the %s when calling method %s of %s of with args', $args, $before->toString(), $method, get_class($this)); } break; } } if ($failed) { return false; } // For around interceptor if (count($interceptors['around']) > 0) { $around = $interceptors['around'][0]; if (count($interceptors['around']) > 1) { $this->warn('The around interceptor for method %s is bigger than 1', $args, $method); } return $around->intercept($method, $args); } // Using git to test if the file has been changed, test this after the interceptors // In order pass the security check. if (file_exists(FCPATH . APPPATH . '.git/HEAD')) { $ref = file_get_contents(FCPATH . APPPATH . '.git/HEAD'); $ref = explode(' ', $ref); $ref = trim($ref[1]); $ref = FCPATH . APPPATH . '.git/' . $ref; } if (get_ci_config('enable_cache') && !isset($this->disable_cache) && isset($ref) && cache_support($ref)) { return; } // Run the original method $ret = $this->_process($method, $args); // Run the after method foreach ($interceptors['after'] as $after) { $after->intercept($method, $args); } return $ret; }