TasksService
- Type
- Class
- Namespace
- Craft
- Inherits
- Craft\TasksService » Craft\BaseApplicationComponent » CApplicationComponent (opens new window) » CComponent (opens new window)
- Implements
IApplicationComponent- Since
- 2.0
Class TasksService
See also http://craftcms.com
View source (opens new window)
# Public Properties
| Property | Description |
|---|---|
| $behaviors (opens new window) | array (opens new window) – The behaviors that should be attached to this component. |
# Public Methods
| Method | Description |
|---|---|
| __call() (opens new window) | Calls the named method which is not a class method. |
| __get() (opens new window) | Returns a property value, an event handler list or a behavior based on its name. |
| __isset() (opens new window) | Checks if a property value is null. |
| __set() (opens new window) | Sets value of a component property. |
| __unset() (opens new window) | Sets a component property to be null. |
| areTasksPending() | Returns whether there are any pending tasks, optionally by a given type. |
| asa() (opens new window) | Returns the named behavior object. |
| attachBehavior() (opens new window) | Attaches a behavior to this component. |
| attachBehaviors() (opens new window) | Attaches a list of behaviors to the component. |
| attachEventHandler() (opens new window) | Attaches an event handler to an event. |
| canGetProperty() (opens new window) | Determines whether a property can be read. |
| canSetProperty() (opens new window) | Determines whether a property can be set. |
| closeAndRun() | Closes the connection with the client and turns the request into a task runner. |
| createTask() | Creates a task to run later in the system. |
| deleteTaskById() | Deletes a task by its ID. |
| detachBehavior() (opens new window) | Detaches a behavior from the component. |
| detachBehaviors() (opens new window) | Detaches all behaviors from the component. |
| detachEventHandler() (opens new window) | Detaches an existing event handler. |
| disableBehavior() (opens new window) | Disables an attached behavior. |
| disableBehaviors() (opens new window) | Disables all behaviors attached to this component. |
| enableBehavior() (opens new window) | Enables an attached behavior. |
| enableBehaviors() (opens new window) | Enables all behaviors attached to this component. |
| evaluateExpression() (opens new window) | Evaluates a PHP expression or callback under the context of this component. |
| fail() | Sets a task's status to "error" and logs it. |
| getAllTasks() | Returns all the tasks. |
| getEventHandlers() (opens new window) | Returns the list of attached event handlers for an event. |
| getIsInitialized() (opens new window) | Checks if this application component has been initialized. |
| getNextPendingTask() | Returns the next pending task. |
| getPendingTasks() | Returns any pending tasks, optionally by a given type. |
| getRunningTask() | Returns the currently running task. |
| getTaskById() | Returns a task by its ID. |
| getTotalTasks() | Returns the total number of active tasks. |
| handleRequestEnd() | Figure out how to initiate a new task runner. |
| hasEvent() (opens new window) | Determines whether an event is defined. |
| hasEventHandler() (opens new window) | Checks whether the named event has attached handlers. |
| hasProperty() (opens new window) | Determines whether a property is defined. |
| haveTasksFailed() | Returns whether any tasks that have failed. |
| init() (opens new window) | Initializes the application component. |
| isInitialized() | Checks if this application component has been initialized yet, or not. |
| isTaskRunning() | Returns whether there is a task that is currently running. |
| raiseEvent() (opens new window) | Raises an event. |
| rerunTaskById() | Re-runs a task by a given ID. |
| runPendingTasks() | Runs any pending tasks. |
| runTask() | Runs a given task. |
| saveTask() | Saves a task. |
# areTasksPending()
Returns whether there are any pending tasks, optionally by a given type.
View source (opens new window)
Arguments
Returns
Signature
public boolean areTasksPending ( $type = null )
# closeAndRun()
Closes the connection with the client and turns the request into a task runner.
View source (opens new window)
Returns
Signature
public null closeAndRun ( )
# createTask()
Creates a task to run later in the system.
View source (opens new window)
Arguments
$type(string (opens new window))$description(string (opens new window), null (opens new window))$settings(array (opens new window), null (opens new window))$parentId(integer (opens new window), null (opens new window))
Returns
Throws
Signature
public Craft\TaskModel createTask ( $type, $description = null, $settings = [], $parentId = null )
# deleteTaskById()
Deletes a task by its ID.
View source (opens new window)
Arguments
$taskId(integer (opens new window))
Returns
Signature
public boolean, null deleteTaskById ( $taskId )
# fail()
Sets a task's status to "error" and logs it.
View source (opens new window)
Arguments
$task(Craft\TaskModel)$error(mixed)
Returns
Signature
public null fail ( Craft\TaskModel $task, $error = null )
# getAllTasks()
Signature
public Craft\TaskModel[] getAllTasks ( )
# getNextPendingTask()
Returns the next pending task.
View source (opens new window)
Arguments
Returns
Craft\TaskModel, null (opens new window), false (opens new window)
Signature
public Craft\TaskModel, null, false getNextPendingTask ( $type = null )
# getPendingTasks()
Returns any pending tasks, optionally by a given type.
View source (opens new window)
Arguments
$type(string (opens new window), null (opens new window))$limit(integer (opens new window), null (opens new window))
Returns
Signature
public Craft\TaskModel[] getPendingTasks ( $type = null, $limit = null )
# getRunningTask()
Signature
public Craft\TaskModel, null getRunningTask ( )
# getTaskById()
Returns a task by its ID.
View source (opens new window)
Arguments
$taskId(integer (opens new window))
Returns
Signature
public Craft\TaskModel, null getTaskById ( $taskId )
# getTotalTasks()
Signature
public integer getTotalTasks ( )
# handleRequestEnd()
Figure out how to initiate a new task runner.
Signature
public void handleRequestEnd ( )
# haveTasksFailed()
Signature
public boolean haveTasksFailed ( )
# isTaskRunning()
Signature
public boolean isTaskRunning ( )
# rerunTaskById()
Re-runs a task by a given ID.
View source (opens new window)
Arguments
$taskId(integer (opens new window))
Returns
Signature
public Craft\TaskModel, null rerunTaskById ( $taskId )
# runPendingTasks()
Signature
public null runPendingTasks ( )
# runTask()
Signature
public boolean runTask ( Craft\TaskModel $task )
# saveTask()
Saves a task.
View source (opens new window)
Arguments
$task(Craft\TaskModel)$validate(boolean (opens new window))
Returns
Signature
public boolean saveTask ( Craft\TaskModel $task, $validate = true )