本文整理汇总了PHP中task::get_definitions方法的典型用法代码示例。如果您正苦于以下问题:PHP task::get_definitions方法的具体用法?PHP task::get_definitions怎么用?PHP task::get_definitions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类task
的用法示例。
在下文中一共展示了task::get_definitions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
static function start($task_callback, $context = array())
{
$tasks = task::get_definitions();
$task = task::create($tasks[$task_callback], array());
$task->log(t("Task %task_name started (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)));
return $task;
}
示例2: start
/**
* Start a new task
* @param string $task_callback
*/
public function start($task_callback)
{
access::verify_csrf();
$tasks = task::get_definitions();
$task = task::create($tasks[$task_callback], array());
$view = new View("admin_maintenance_task.html");
$view->task = $task;
log::info("tasks", t("Task %task_name started (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), html::anchor(url::site("admin/maintenance"), t("maintenance")));
print $view;
}
示例3: index
/**
* Show a list of all available, running and finished tasks.
*/
public function index()
{
$query = db::build()->update("tasks")->set("state", "stalled")->where("done", "=", 0)->where("state", "<>", "stalled")->where(new Database_Expression("UNIX_TIMESTAMP(NOW()) - `updated` > 15"))->execute();
$stalled_count = $query->count();
if ($stalled_count) {
log::warning("tasks", t2("One task is stalled", "%count tasks are stalled", $stalled_count), t('<a href="%url">view</a>', array("url" => html::mark_clean(url::site("admin/maintenance")))));
}
$view = new Admin_View("admin.html");
$view->page_title = t("Maintenance tasks");
$view->content = new View("admin_maintenance.html");
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")->where("done", "=", 0)->order_by("updated", "DESC")->find_all();
$view->content->finished_tasks = ORM::factory("task")->where("done", "=", 1)->order_by("updated", "DESC")->find_all();
print $view;
}