Skip to content

classes_tasks_task.class

Daniel Spors edited this page Dec 19, 2023 · 3 revisions

Classes in file tasks/task.class.php

abstract class Task

Represents some work to be done. Processes defined in Task class can be run from different SAPI. You may create and run the directly: MyTask::Make()->DoMyWork() You may delay them using WdfTaskModel and the WDF cli backend: MyTask::Async('DoMyWork')->Go() You may execute them from command line: php index.php mytask-domywork

Subclasses: CheckTask, ClearTask, CreateTask, DbTask, DevServer, PdfPrintTask, TaskPool, WdfCronTask, WebRequest

Async

Creates a WdfTaskModel for async processing.

Definition: public static function Async($method)

Returns: \ScavixWDF\Tasks\WdfTaskModel

Parameters:

  • string $method Optional method name to be started.

AsyncOnce

Creates a WdfTaskModel for async processing if it not already exists.

Definition: public static function AsyncOnce($method, $return_original=false, $args=false)

Returns: \ScavixWDF\Tasks\WdfTaskModel The new task or a dummy if already present or the one already present

Parameters:

  • string $method Optional method name to be started.

  • bool $return_original If true and there's already another task present, return that one, else return a dummy if there's another one

  • mixed $args Optional arguments

Finished

Called once the Task finished processing.

Definition: public function Finished($method, $runtime, $exectime)

Returns: void

Parameters:

  • string $method The method processed

  • int $runtime The total time from creation/start till not in ms

  • int $exectime The time in ms needed for actual execution (Run method)

Fork

Runs this task in another (CLI) process.

Definition: public function Fork($args, $method, $return_cmdline=false)

Returns: void|string

Parameters:

  • array $args Arguments

  • string $method Optional method name

  • bool $return_cmdline If true, process will not be started, but it's commandline is returned.

IsRunning

Checks if another Task is already running.

Definition: public static function IsRunning($method, $args=false)

Returns: bool true if present, else false

Parameters:

  • string $method Task method to check for (default: run)

  • array|false $args Optional arguments to check for (default: false)

Make

Generic static construction method that can be called on subclasses. Sample: MyTask::Make()->DoWork();

Definition: public static function Make()

Returns: static

PreprocessArguments

Subclasses may implement this to react on arguments before actual run.

Definition: public function PreprocessArguments($args)

Returns: array New array with arguments

Parameters:

  • array $args Array with arguments

Run

Central processing method. Subclasses must implement this.

Definition: public abstract function Run($args)

Returns: void

Parameters:

  • array $args Array with arguments

__construct

Definition: public function __construct(WdfTaskModel $model=null)

Returns: NOT DOCUMENTED

Parameters:

  • $model [default: null] NOT DOCUMENTED
Clone this wiki locally