-
Notifications
You must be signed in to change notification settings - Fork 34
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 $methodOptional 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 $methodOptional method name to be started. -
bool $return_originalIf true and there's already another task present, return that one, else return a dummy if there's another one -
mixed $argsOptional arguments
Called once the Task finished processing.
Definition: public function Finished($method, $runtime, $exectime)
Returns: void
Parameters:
-
string $methodThe method processed -
int $runtimeThe total time from creation/start till not in ms -
int $exectimeThe 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 $argsArguments -
string $methodOptional method name -
bool $return_cmdlineIf 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 $methodTask method to check for (default: run) -
array|false $argsOptional arguments to check for (default: false)
Kills a running Task identifier by it's name. The name is calculated from the 'run'-method and the given arguments (see Task::Async and Task::AsyncOnce).
Definition: public static function Kill($method, $args=false)
Returns: bool True if killed, else false
Parameters:
-
mixed $methodThe run-method (default: run) -
mixed $argsOptional arguments given to the task at creation
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 $argsArray with arguments
Central processing method. Subclasses must implement this.
Definition: public abstract function Run($args)
Returns: void
Parameters:
-
array $argsArray with arguments
Definition: public function __construct(WdfTaskModel $model=null)
Returns: NOT DOCUMENTED
Parameters:
-
$model [default: null]NOT DOCUMENTED