You are here

public function JobItem::addMessage in Translation Management Tool 8

Add a log message for this job item.

Parameters

string $message: The message to store in the log. Keep $message translatable by not concatenating dynamic values into it! Variables in the message should be added by using placeholder strings alongside the variables argument to declare the value of the placeholders. See t() for documentation on how $message and $variables interact.

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

string $type: (Optional) The type of the message. Can be one of 'status', 'error', 'warning' or 'debug'. Messages of the type 'debug' will not get printed to the screen.

Return value

string \Drupal\tmgmt\MessageInterface

Overrides JobItemInterface::addMessage

4 calls to JobItem::addMessage()
JobItem::addTranslatedDataRecursive in src/Entity/JobItem.php
Recursively writes translated data to the data array of a job item.
JobItem::dataItemRevert in src/Entity/JobItem.php
Reverts data item translation to the latest existing revision.
JobItem::needsReview in src/Entity/JobItem.php
Sets the state of the job item to 'needs review'.
JobItem::setState in src/Entity/JobItem.php
Updates the state of the job item.

File

src/Entity/JobItem.php, line 287

Class

JobItem
Entity class for the tmgmt_job_item entity.

Namespace

Drupal\tmgmt\Entity

Code

public function addMessage($message, $variables = array(), $type = 'status') {

  // Save the job item if it hasn't yet been saved.
  if (!$this
    ->isNew() || $this
    ->save()) {
    $message = tmgmt_message_create($message, $variables, array(
      'tjid' => $this
        ->getJobId(),
      'tjiid' => $this
        ->id(),
      'type' => $type,
    ));
    if ($message
      ->save()) {
      return $message;
    }
  }
}