function config($name, $def = null) { return \taskman_config($name, $def); }
function run($args = array()) { global $TASKMAN_CURRENT_TASK; global $TASKMAN_STACK; $args_str = serialize($args); if (isset($this->has_run[$args_str]) && $this->has_run[$args_str] || $this->is_running) { return; } $this->is_running = true; $this->args = $args; try { if ($task_handler = taskman_config('task_handler')) { $task_handler($this); } taskman_runtasks($this->_getBeforeDeps(), $this->args); taskman_runtasks($this->_getDeps(), $this->args); taskman_sysmsg("************************ Running task '" . $this->getName() . "' ************************\n"); $bench = microtime(true); $TASKMAN_CURRENT_TASK = $this; $TASKMAN_STACK[] = $this; if ($replacer = $this->_getReplacingTask()) { taskman_runtask($replacer, $this->args); } else { call_user_func_array($this->func, array($this->args)); } array_pop($TASKMAN_STACK); taskman_runtasks($this->_getAfterDeps(), $this->args); taskman_sysmsg("************************* '" . $this->getName() . "' done (" . round(microtime(true) - $bench, 2) . " sec.)*************************\n"); $this->has_run[$args_str] = true; $this->is_running = false; } catch (Exception $e) { if ($error_handler = taskman_config('error_handler')) { $error_handler($e); } else { throw $e; } } }