Updates the state of the job.
int $state: The new state of the job. Has to be one of the job state constants.
string $message: (optional) The log message to be saved along with the state change.
array $variables: (optional) An array of variables to replace in the message on display.
string $type: (optional) The message type.
int The updated state of the job if it could be set.
Overrides JobInterface::setState
public function setState($state, $message = NULL, $variables = array(), $type = 'debug') {
// Return TRUE if the state could be set. Return FALSE otherwise.
if (array_key_exists($state, Job::getStates())) {
$this->state = $state;
$this
->save();
// If a message is attached to this state change add it now.
if (!empty($message)) {
$this
->addMessage($message, $variables, $type);
}
}
return $this
->getState();
}