public static function add($controller_name, $method_name, $parameters = array(), $priority = 5, $application_path = '') { if ($priority < 1 or $priority > 10) { Kohana::log('error', 'The priority of the task was out of range!'); return FALSE; } $application_path = empty($application_path) ? APPPATH : $application_path; $old_module_list = Kohana::config('core.modules'); Kohana::config_set('core.modules', array_merge($old_module_list, array($application_path))); // Make sure the controller name and method are valid if (Kohana::auto_load($controller_name)) { // Only add it to the queue if the controller method exists if (Kohana::config('queue.validate_methods') and !method_exists($controller_name, $method_name)) { Kohana::log('error', 'The method ' . $controller_name . '::' . $method_name . ' does not exist.'); return FALSE; } // Add the action to the run queue with the priority $task = new Task_Model(); $task->set_fields(array('application' => $application_path, 'class' => $controller_name, 'method' => $method_name, 'params' => serialize($parameters), 'priority' => $priority)); $task->save(); // Restore the module list Kohana::config_set('core.modules', $old_module_list); return TRUE; } Kohana::log('error', 'The class ' . $controller_name . ' does not exist.'); return FALSE; }