function JobForm::addSuggestionItem

Create a Suggestion-Table entry based on a Job and a title.

Parameters

array $result: Suggestion array with the keys job_item, reason and from_item.

Return value

array Options-Entry for a tableselect array.

1 call to JobForm::addSuggestionItem()
JobForm::buildSuggestions in src/Form/JobForm.php
Fills the tableselect with all translation suggestions.

File

src/Form/JobForm.php, line 853

Class

JobForm
Form controller for the job edit forms.

Namespace

Drupal\tmgmt\Form

Code

function addSuggestionItem(array $result) {
  $item = $result['job_item'];
  $reason = isset($result['reason']) ? $result['reason'] : NULL;
  $option = array(
    'title' => $item
      ->label(),
    'type' => $item
      ->getSourceType(),
    'words' => $item
      ->getWordCount(),
    'tags' => $item
      ->getTagsCount(),
    'reason' => $reason,
  );
  if (!empty($result['from_item'])) {
    $from_item = JobItem::load($result['from_item']);
    if ($from_item) {
      $option['reason'] = t('%reason in %job', array(
        '%reason' => $option['reason'],
        '%job' => $from_item
          ->label(),
      ));
    }
  }
  return $option;
}