public function Job::getItems

Returns all job items attached to this job.

Parameters

array $conditions: Additional conditions.

Return value

\Drupal\tmgmt\JobItemInterface[] An array of translation job items.

Overrides JobInterface::getItems

9 calls to Job::getItems()
Job::aborted in src/Entity/Job.php
Sets the state of the job to 'aborted'.
Job::acceptTranslation in src/Entity/Job.php
Propagates the returned job item translations to the sources.
Job::addTranslatedData in src/Entity/Job.php
Store translated data back into the items.
Job::getConflictingItems in src/Entity/Job.php
Returns conflicting job item IDs along with the jobs causing the conflicts.
Job::getData in src/Entity/Job.php
Returns the source data of all job items.

... See full list

File

src/Entity/Job.php, line 390

Class

Job
Entity class for the tmgmt_job entity.

Namespace

Drupal\tmgmt\Entity

Code

public function getItems($conditions = array()) {
  $items = [];
  $query = \Drupal::entityQuery('tmgmt_job_item')
    ->accessCheck(TRUE)
    ->condition('tjid', $this
    ->id());
  foreach ($conditions as $key => $condition) {
    if (is_array($condition)) {
      $operator = isset($condition['operator']) ? $condition['operator'] : '=';
      $query
        ->condition($key, $condition['value'], $operator);
    }
    else {
      $query
        ->condition($key, $condition);
    }
  }
  $query
    ->sort('tjiid', 'ASC');
  $results = $query
    ->execute();
  if (!empty($results)) {
    $items = \Drupal::entityTypeManager()
      ->getStorage('tmgmt_job_item')
      ->loadMultiple($results);
    if ($this->filterTranslatedItems) {
      $items = array_filter($items, function (JobItemInterface $item) {
        return $item
          ->getCountPending() > 0;
      });
    }
  }
  return $items;
}