public function JobItem::getData

Array of the data to be translated.

The structure is similar to the form API in the way that it is a possibly nested array with the following properties whose presence indicate that the current element is a text that might need to be translated.

  • #text: The text to be translated.
  • #label: (Optional) The label that might be shown to the translator.
  • #comment: (Optional) A comment with additional information.
  • #translate: (Optional) If set to FALSE the text will not be translated.
  • #translation: The translated data. Set by the translator plugin.
  • #escape: (Optional) List of arrays with a required string key, keyed by the position key. Translators must use this list to prevent translation of these strings if possible.

@todo: Move data item documentation to a new, separate api group.

The key can be any alphanumeric character and '_'.

Parameters

array $key: If present, only the subarray identified by key is returned.

int $index: Optional index of an attribute below $key.

Return value

array A structured data array.

Overrides JobItemInterface::getData

4 calls to JobItem::getData()
JobItem::addTranslatedData in src/Entity/JobItem.php
Adds translated data to a job item.
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::resetData in src/Entity/JobItem.php
Resets job item data arrays.

File

src/Entity/JobItem.php, line 382

Class

JobItem
Entity class for the tmgmt_job_item entity.

Namespace

Drupal\tmgmt\Entity

Code

public function getData($key = array(), $index = NULL) {
  $this
    ->decodeData();
  if (empty($this->unserializedData) && $this
    ->getJobId()) {

    // Load the data from the source if it has not been set yet.
    $this->unserializedData = $this
      ->getSourceData();
    $this
      ->save();
  }
  if (empty($key)) {
    return $this->unserializedData;
  }
  if ($index) {
    $key = array_merge($key, array(
      $index,
    ));
  }
  return NestedArray::getValue($this->unserializedData, $key);
}