classes_tasks_task.class
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
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.
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
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)
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.
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)
Generic static construction method that can be called on subclasses.
Sample: MyTask::Make()->DoWork();
Definition: public static function Make()
Returns: static
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
Central processing method. Subclasses must implement this.
Definition: public abstract function Run($args)
Returns: void
Parameters:
-
array $args
Array with arguments
Definition: public function __construct(WdfTaskModel $model=null)
Returns: NOT DOCUMENTED
Parameters:
-
$model [default: null]
NOT DOCUMENTED