You are here

public function TMGMTJob::getData in Translation Management Tool 7

Returns the source data of all job items.

Parameters

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

$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.

File

entity/tmgmt.entity.job.inc, line 682

Class

TMGMTJob
Entity class for the tmgmt_job entity.

Code

public function getData(array $key = array(), $index = NULL) {
  $data = array();
  if (!empty($key)) {
    $tjiid = array_shift($key);
    $item = entity_load_single('tmgmt_job_item', $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;
}