WIP additional revision information

This commit is contained in:
Paul Weidner 2023-09-07 16:24:49 -07:00
parent 4ce643bb1a
commit dabe3f4b47
1 changed files with 15 additions and 0 deletions

View File

@ -128,6 +128,21 @@ class GinContentFormBase extends ContentEntityForm implements RenderCallbackInte
}
}
// Add authoring information for existing entities.
// @todo Dependency injection.
if (!$this->entity->isNew()) {
$changed = \Drupal::service('date.formatter')->format($this->entity->getChangedTime(), 'short', '', $this->currentUser()->getTimeZone(), '');
$created = \Drupal::service('date.formatter')->format($this->entity->getCreatedTime(), 'short', '', $this->currentUser()->getTimeZone(), '');
$form['revision_field_group']['revision_meta'] = [
'#theme' => 'item_list',
'#items' => [
$this->t('Author: @author', ['@author' => $this->entity->getOwner()->getAccountName()]),
$this->t('Last saved: @timestamp', ['@timestamp' => $changed]),
$this->t('Created: @timestamp', ['@timestamp' => $created]),
],
];
}
return $form;
}