You are here

public function Job::getData in Translation Management Tool 8

Returns the source data of all job items.

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 nested array with the source data where the most upper key is the job item id.

Overrides JobInterface::getData

File

src/Entity/Job.php, line 801

Class

Job
Entity class for the tmgmt_job entity.

Namespace

Drupal\tmgmt\Entity

Code

public function getData($key = array(), $index = NULL) {
  $data = array();
  if (!empty($key)) {
    $tjiid = array_shift($key);
    $item = JobItem::load($tjiid);
    if ($item) {
      $data[$tjiid] = $item
        ->getData($key, $index);

      // If not set, use the job item label as the data label.
      if (!isset($data[$tjiid]['#label'])) {
        $data[$tjiid]['#label'] = $item
          ->getSourceLabel();
      }
    }
  }
  else {
    foreach ($this
      ->getItems() as $tjiid => $item) {
      $data[$tjiid] = $item
        ->getData();

      // If not set, use the job item label as the data label.
      if (!isset($data[$tjiid]['#label'])) {
        $data[$tjiid]['#label'] = $item
          ->getSourceLabel();
      }
    }
  }
  return $data;
}