TasksService

Type
Class
Namespace
Craft
Inherits
Craft\TasksService » Craft\BaseApplicationComponent » CApplicationComponent » CComponent
Implements
IApplicationComponent
Since
2.0

Class TasksService

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$behaviorsarray – The behaviors that should be attached to this component.

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__unset()Sets a component property to be null.
areTasksPending()Returns whether there are any pending tasks, optionally by a given type.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
canGetProperty()Determines whether a property can be read.
canSetProperty()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()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
evaluateExpression()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()Returns the list of attached event handlers for an event.
getIsInitialized()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()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
haveTasksFailed()Returns whether any tasks that have failed.
init()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()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

Arguments

Returns

boolean

Signature

public boolean areTasksPending ( $type = null )

closeAndRun()

Closes the connection with the client and turns the request into a task runner.

View source

Returns

null

Signature

public null closeAndRun ( )

createTask()

Creates a task to run later in the system.

View source

Arguments

Returns

Craft\TaskModel

Throws

Signature

public Craft\TaskModel createTask ( $type, $description = null, $settings = [], $parentId = null )

deleteTaskById()

Deletes a task by its ID.

View source

Arguments

Returns

boolean, null

Signature

public boolean, null deleteTaskById ( $taskId )

fail()

Sets a task's status to "error" and logs it.

View source

Arguments

Returns

null

Signature

public null fail ( Craft\TaskModel $task, $error = null )

getAllTasks()

Returns all the tasks.

View source

Returns

Craft\TaskModel[]

Signature

public Craft\TaskModel[] getAllTasks ( )

getNextPendingTask()

Returns the next pending task.

View source

Arguments

Returns

Craft\TaskModel, null, false

Signature

public Craft\TaskModel, null, false getNextPendingTask ( $type = null )

getPendingTasks()

Returns any pending tasks, optionally by a given type.

View source

Arguments

Returns

Craft\TaskModel[]

Signature

public Craft\TaskModel[] getPendingTasks ( $type = null, $limit = null )

getRunningTask()

Returns the currently running task.

View source

Returns

Craft\TaskModel, null

Signature

public Craft\TaskModel, null getRunningTask ( )

getTaskById()

Returns a task by its ID.

View source

Arguments

Returns

Craft\TaskModel, null

Signature

public Craft\TaskModel, null getTaskById ( $taskId )

getTotalTasks()

Returns the total number of active tasks.

View source

Returns

integer

Signature

public integer getTotalTasks ( )

handleRequestEnd()

Figure out how to initiate a new task runner.

View source

Signature

public void handleRequestEnd ( )

haveTasksFailed()

Returns whether any tasks that have failed.

View source

Returns

boolean

Signature

public boolean haveTasksFailed ( )

isTaskRunning()

Returns whether there is a task that is currently running.

View source

Returns

boolean

Signature

public boolean isTaskRunning ( )

rerunTaskById()

Re-runs a task by a given ID.

View source

Arguments

Returns

Craft\TaskModel, null

Signature

public Craft\TaskModel, null rerunTaskById ( $taskId )

runPendingTasks()

Runs any pending tasks.

View source

Returns

null

Signature

public null runPendingTasks ( )

runTask()

Runs a given task.

View source

Arguments

Returns

boolean

Signature

public boolean runTask ( Craft\TaskModel $task )

saveTask()

Saves a task.

View source

Arguments

Returns

boolean

Signature

public boolean saveTask ( Craft\TaskModel $task, $validate = true )