/**
  * {@inheritdoc}
  */
 protected function getRevisionDescription(ContentEntityInterface $revision, $is_default = FALSE)
 {
     /** @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\user\EntityOwnerInterface|\Drupal\Core\Entity\RevisionLogInterface $revision */
     if ($revision instanceof RevisionLogInterface) {
         // Use revision link to link to revisions that are not active.
         $date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
         $link = $revision->toLink($date, 'revision');
         // @todo: Simplify this when https://www.drupal.org/node/2334319 lands.
         $username = ['#theme' => 'username', '#account' => $revision->getRevisionUser()];
         $username = $this->renderer->render($username);
     } else {
         $link = $revision->toLink($revision->label(), 'revision');
         $username = '';
     }
     $markup = '';
     if ($revision instanceof RevisionLogInterface) {
         $markup = $revision->getRevisionLogMessage();
     }
     if ($username) {
         $template = '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}';
     } else {
         $template = '{% trans %} {{ date }} {% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}';
     }
     $column = ['data' => ['#type' => 'inline_template', '#template' => $template, '#context' => ['date' => $link->toString(), 'username' => $username, 'message' => ['#markup' => $markup, '#allowed_tags' => Xss::getHtmlTagList()]]]];
     return $column;
 }
 /**
  * Builds a table row for overview form.
  *
  * @param array ContentEntityInterface $entity
  *   Data needed to build the list row.
  * @param array $bundles
  *   The array of bundles.
  *
  * @return array
  */
 public function overviewRow(ContentEntityInterface $entity, array $bundles)
 {
     $label = $entity->label() ?: $this->t('@type: @id', array('@type' => $entity->getEntityTypeId(), '@id' => $entity->id()));
     // Get existing translations and current job items for the entity
     // to determine translation statuses
     $translations = $entity->getTranslationLanguages();
     $source_lang = $entity->language()->getId();
     $current_job_items = tmgmt_job_item_load_latest('content', $entity->getEntityTypeId(), $entity->id(), $source_lang);
     $row = array('id' => $entity->id(), 'title' => $entity->hasLinkTemplate('canonical') ? $entity->toLink($label, 'canonical')->toString() : ($entity->label() ?: $entity->id()));
     if (count($bundles) > 1) {
         $row['bundle'] = isset($bundles[$entity->bundle()]) ? $bundles[$entity->bundle()] : t('Unknown');
     }
     // Load entity translation specific data.
     $manager = \Drupal::service('content_translation.manager');
     foreach (\Drupal::languageManager()->getLanguages() as $langcode => $language) {
         $translation_status = 'current';
         if ($langcode == $source_lang) {
             $translation_status = 'original';
         } elseif (!isset($translations[$langcode])) {
             $translation_status = 'missing';
         } elseif ($translation = $entity->getTranslation($langcode)) {
             $metadata = $manager->getTranslationMetadata($translation);
             if ($metadata->isOutdated()) {
                 $translation_status = 'outofdate';
             }
         }
         $build = $this->buildTranslationStatus($translation_status, isset($current_job_items[$langcode]) ? $current_job_items[$langcode] : NULL);
         $row['langcode-' . $langcode] = ['data' => \Drupal::service('renderer')->render($build), 'class' => array('langstatus-' . $langcode)];
     }
     return $row;
 }