本文整理汇总了PHP中Task类的典型用法代码示例。如果您正苦于以下问题:PHP Task类的具体用法?PHP Task怎么用?PHP Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add(Task $task)
{
if (!$this->hasUniqueTaskName($task->name())) {
throw new Exception(sprintf('Task name (%s) is not unique!', $task->name()));
}
$this->tasks[] = $task;
}
示例2: testIsRunning
public function testIsRunning()
{
$task = new Task(['exec' => 'sleep 1']);
$this->assertFalse($task->isRunning());
$task->run();
$this->assertTrue($task->isRunning());
}
示例3: process
public function process(Task $task = null)
{
if (empty($task)) {
$task = new Task($this->path, $this->filename, $this->extension, $this->config['public_path']);
}
// Can we read the original file and write in the original path?
if (!$task->isValid()) {
return $this->halt();
}
// Can we operate in this path?
if (!preg_match($this->config['path_mask'], trim(str_replace($this->config['public_path'], '', $task->origPath), DIRECTORY_SEPARATOR))) {
return $this->halt();
}
// Is a valid task name and can we call the action?
$callable = $this->getActionCallable($task->name);
if ($callable === false) {
return $this->halt();
} else {
$task->image = \WideImage\WideImage::load($task->origFile);
// Create destination path
if (!file_exists($task->destPath) and !is_dir($task->destPath)) {
@mkdir($task->destPath, 0775, true);
}
if (call_user_func($callable, $task) !== false) {
// If the action does not return false explicitly...
$this->reload();
// SUCCESS exit point: reload the image URL
}
}
$this->halt();
}
示例4: run
public function run()
{
$this->db->query("UPDATE " . DB_PREFIX . "customer c \r\n SET congrats = 1 \r\n WHERE DAY(birthday) <> '" . $this->db->escape(date('d')) . "' \r\n AND MONTH(birthday) <> '" . $this->db->escape(date('m')) . "'");
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer c \r\n WHERE DAY(birthday) = '" . $this->db->escape(date('d')) . "' \r\n AND MONTH(birthday) = '" . $this->db->escape(date('m')) . "'\r\n AND congrats = 1");
if ($query->num_rows && (int) $this->config->get('marketing_email_happy_birthday')) {
$params = array('job' => 'send_birthday', 'newsletter_id' => (int) $this->config->get('marketing_email_happy_birthday'));
$this->load->library('task');
$task = new Task($this->registry);
$task->object_id = (int) $this->config->get('marketing_email_happy_birthday');
$task->object_type = 'newsletter';
$task->task = 'happy_birthday';
$task->type = 'send';
$task->time_exec = date('Y-m-d') . ' 08:00:00';
$task->params = $params;
$task->time_interval = "";
$task->time_last_exec = "";
$task->run_once = true;
$task->status = 1;
$task->date_start_exec = date('Y-m-d') . ' 08:00:00';
$task->date_end_exec = date('Y-m-d') . ' 23:00:00';
foreach ($query->rows as $customer) {
$params = array('customer_id' => $customer['customer_id'], 'fullname' => $customer['firstname'] . " " . $customer['lastname'], 'company' => $customer['company'], 'rif' => $customer['rif'], 'telephone' => $customer['telephone'], 'email' => $customer['email']);
$queue = array("params" => $params, "status" => 1, "time_exec" => date('Y-m-d') . ' 08:00:00');
$task->addQueue($queue);
$this->db->query("UPDATE " . DB_PREFIX . "customer c SET congrats = 0 WHERE customer_id = '" . (int) $customer['customer_id'] . "'");
}
$task->createSendTask();
}
}
示例5: __construct
/**
* Constructs the entity
*
* @access public
* @param \Zepi\Core\Utils\Entity\Task $task
* @param integer $pid
*/
public function __construct(Task $task, $pid)
{
$this->task = $task;
$this->pid = $pid;
$this->startTime = time();
$this->restartTime = time() + $task->getResetTime() + rand(1, 5);
}
示例6: get
function get($criteria = null, $order = null)
{
$sql = "SELECT tasks.*, CONCAT(users.first_name, ' ', users.last_name) AS assigned_to_name\n FROM tasks\n LEFT JOIN users ON users.id = tasks.assigned_to";
if (isset($criteria) && is_numeric($criteria)) {
$sql .= " WHERE tasks.id = {$criteria}";
$task = parent::get_one($sql);
$this->update_status();
return $task;
} else {
$sql = $this->add_criteria($sql, $criteria);
$sql = $this->modify_sql_for_user_type($sql);
$sql = $this->add_order_by($sql, $order);
$tasks = parent::get($sql);
foreach ($tasks as &$task) {
//create the invoice
$task_object = new Task($task);
//todo: i don't think this makes any sense because the invoice status will already be updated when I create the invoice using new Invoice
//store the current task status as it exists in the database
$old_status = $task_object->status_text;
//update the task status
$task_object->update_status();
//if the old status and the new status do not match, then we need to save this task back to the database.
if ($old_status != (string) $task_object->status_text) {
//todo:make sure this isn't saving each time
$task_object->save(false);
}
//we need to add the status text back the task array, since we're sending the array to the client,
//not the object
$task['status_text'] = $task_object->status_text;
}
return $tasks;
}
}
示例7: view
function view($id = null)
{
if (is_null($id)) {
echo "error: no id supplied";
return false;
}
$this->load->library('bitly');
$this->form_validation->set_rules('name', 'Task Name', 'required|trim');
$data = array();
$docket = new Docket();
$task = new Task();
$user = new User();
if (!$docket->where('shared', 1)->where('id', $id)->count()) {
redirect('dockets');
} else {
$data['docket'] = $docket->get_by_id($id);
}
if ($docket->short_url == '') {
$docket->short_url = $this->bitly->shorten(base_url() . 'index.php/pub/view/' . $docket->id);
$docket->save();
}
if ($task->where('completed', 0)->where_related_docket('id', $docket->id)->count() == 0) {
$data['pending_tasks'] = array();
} else {
$data['pending_tasks'] = $task->where('completed', 0)->where_related_docket('id', $docket->id)->get()->all;
}
if ($task->where('completed', 1)->where_related_docket('id', $docket->id)->count() == 0) {
$data['completed_tasks'] = array();
} else {
$data['completed_tasks'] = $task->where('completed', 1)->where_related_docket('id', $docket->id)->get()->all;
}
$data['user'] = $user->get_by_id($docket->user_id);
$this->load->view('pub/view', $data);
}
示例8: find
public function find($id)
{
$events = $this->eventStore->find($id);
$task = new Task();
$task->replay($events);
return $task;
}
示例9: load
public function load($clusterName)
{
$result = $this->awsClient->listTasks(['cluster' => $clusterName, 'serviceName' => $this->serviceName, 'maxResults' => 99, 'nextToken' => '']);
//get existing tasks
foreach ($result['taskArns'] as $taskArn) {
$task = new Task();
$task->setArn($taskArn);
if (!$task->init($this->creds)) {
return false;
}
if (!$task->load($clusterName)) {
return false;
}
$this->tasks[$taskArn] = $task;
}
//get task def
$details = $this->awsClient->describeServices(['cluster' => $clusterName, 'services' => [$this->serviceName]]);
$this->taskDefinition = $details['services'][0]['taskDefinition'];
$this->taskDef = new TaskDef();
$this->taskDef->init($this->creds);
$this->taskDef->load($this->taskDefinition);
//other service items
$this->status = $details['services'][0]['status'];
$this->minHealthyPercent = $details['services'][0]['deploymentConfiguration']['minimumHealthyPercent'];
$this->maxPercent = $details['services'][0]['deploymentConfiguration']['maximumPercent'];
$this->desiredTaskCount = $details['services'][0]['desiredCount'];
$this->pendingTaskCount = $details['services'][0]['pendingCount'];
$this->runningTaskCount = $details['services'][0]['runningCount'];
return true;
}
示例10: delete
function delete()
{
$delete_result = parent::delete();
$task = new Task($this->task_id);
$task->update_total_time();
return $delete_result;
}
示例11: createtask_POST
function createtask_POST(Web &$w)
{
$w->Task->navigation($w, "Create Task");
// unserialise input from step I and store in array: arr_req
$arr_req = unserialize($w->request('formone'));
// set relevant dt variables with: Today.
$arr_req['dt_assigned'] = Date('c');
$arr_req['dt_first_assigned'] = Date('c');
// insert Task into database
$task = new Task($w);
$task->fill($arr_req);
$task->insert();
// if insert is successful, store additional fields as task data
// we do not want to store data from step I, the task_id (as a key=>value pair) nor the FLOW_SID
if ($task->id) {
foreach ($_POST as $name => $value) {
if ($name != "formone" && $name != "FLOW_SID" && $name != "task_id" && $name !== CSRF::getTokenID()) {
$tdata = new TaskData($w);
$arr = array("task_id" => $task->id, "key" => $name, "value" => $value);
$tdata->fill($arr);
$tdata->insert();
unset($arr);
}
}
// return to task dashboard
$w->msg("Task " . $task->title . " added", "/task/viewtask/" . $task->id);
} else {
// if task insert was unsuccessful, say as much
$w->msg("The Task could not be created. Please inform the IT Group", "/task/index/");
}
}
示例12: after
public function after()
{
echo "after\n";
$insert = 0;
// 判断是否插入表
$class_name = get_class($this);
$type = str_replace('Event', '', $class_name);
$task = new Task();
if ($this->event_rs['err_no'] > 0) {
// 代表错误
$task->is_success = 0;
$this->event_rs['class'] = $this->class;
$this->event_rs['param'] = $this->param;
if ($this->retry_cnt >= 3) {
$insert = 1;
}
} else {
$task->is_success = 1;
$insert = 1;
}
// 成功则入库 第一次失败则不入库 第三次失败才一起入库
$task->create_time = time();
$task->retry_cnt = $this->retry_cnt;
$task->event = $type;
$task->param = json_encode($this->param);
if ($insert > 0) {
$task->save();
}
$this->event_rs['retry_cnt'] = $this->retry_cnt;
}
示例13: addTask
/**
* Proxies task adding.
*
* @param Task The task that is being added.
*
* @author Noah Fontes <noah.fontes@bitextender.com>
* @since 1.0.0
*/
public function addTask(Task $task)
{
if ($this->target === null) {
throw new BuildException('Tasks can not be added to a proxy target without a concrete target');
}
$task->setOwningTarget($this->target);
$this->target->addTask($task);
}
示例14: smarty_function_task
/**
* get task information for the specified task
*/
function smarty_function_task($params, &$smarty)
{
$t = new Task();
if (!Check::digits($params['task_id'], $empty = false)) {
return;
}
$smarty->assign('task', $t->getone($params['task_id']));
}
示例15: smarty_function_forms
/**
* take our raw form data and make a data structure out of it
* that can be used in templates
*/
function smarty_function_forms($params, &$smarty)
{
if (!Check::digits($params['task_id'], $empty = false)) {
return;
}
$t = new Task();
$smarty->assign('forms', $t->parseforms($params['task_id']));
}