You are here

public function TMGMTJobItem::setState in Translation Management Tool 7

Updates the state of the job item.

Parameters

$state: The new state of the job item. Has to be one of the job state constants.

$message: (Optional) The log message to be saved along with the state change.

$variables: (Optional) An array of variables to replace in the message on display.

Return value

int The updated state of the job if it could be set.

See also

TMGMTJob::addMessage()

3 calls to TMGMTJobItem::setState()
TMGMTJobItem::accepted in entity/tmgmt.entity.job_item.inc
Sets the state of the job item to 'accepted'.
TMGMTJobItem::active in entity/tmgmt.entity.job_item.inc
Sets the state of the job item to 'active'.
TMGMTJobItem::needsReview in entity/tmgmt.entity.job_item.inc
Sets the state of the job item to 'needs review'.

File

entity/tmgmt.entity.job_item.inc, line 464

Class

TMGMTJobItem
Entity class for the tmgmt_job entity.

Code

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, tmgmt_job_item_states()) && $this->state != $state) {
    $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->state;
}