diff --git a/src/Controller/RevisionOverviewController.php b/src/Controller/RevisionOverviewController.php index 7dd0c9d73362d470ba8a0ff290002a654214328a..c92410ee19be63c32b6207adb0d3d1ef44a168da 100644 --- a/src/Controller/RevisionOverviewController.php +++ b/src/Controller/RevisionOverviewController.php @@ -13,6 +13,7 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Render\RendererInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Entity\RevisionLogInterface; use Drupal\user\EntityOwnerInterface; @@ -35,21 +36,29 @@ class RevisionOverviewController extends ControllerBase { */ protected $dateFormatter; + /** + * The renderer. + * + * @var \Drupal\Core\Render\RendererInterface + */ + protected $renderer; + /** * Creates a new RevisionOverviewController instance. * * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter * The date formatter. */ - public function __construct(DateFormatterInterface $date_formatter) { + public function __construct(DateFormatterInterface $date_formatter, RendererInterface $renderer) { $this->dateFormatter = $date_formatter; + $this->renderer = $renderer; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static($container->get('date.formatter')); + return new static($container->get('date.formatter'), $container->get('renderer')); } /** @@ -106,10 +115,12 @@ class RevisionOverviewController extends ControllerBase { $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'); diff --git a/src/Form/RevisionRevertForm.php b/src/Form/RevisionRevertForm.php index 926a1000dd3cf34358cc2779e3846310dfb3f119..a238dab98f0fdbbbbf2fc1dfd8801d784caa1d20 100644 --- a/src/Form/RevisionRevertForm.php +++ b/src/Form/RevisionRevertForm.php @@ -74,7 +74,7 @@ class RevisionRevertForm extends ConfirmFormBase { */ public function getQuestion() { if ($this->revision instanceof RevisionLogInterface) { - return $this->t('Are you sure you want to revert to the revision from %revision-date?', ['%revision-date' => $this->dateFormatter->format($this->revision->getRevisionLogMessage())]); + return $this->t('Are you sure you want to revert to the revision from %revision-date?', ['%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime())]); } return $this->t('Are you sure you want to revert the revision?'); } diff --git a/tests/src/Kernel/RevisionBasicUITest.php b/tests/src/Kernel/RevisionBasicUITest.php index 5cb764926b49126b012daaaf03e1fadc3bac00be..f452efc4e1efa3ea7d9e3c61676a2bb4aa15108e 100644 --- a/tests/src/Kernel/RevisionBasicUITest.php +++ b/tests/src/Kernel/RevisionBasicUITest.php @@ -33,6 +33,7 @@ class RevisionBasicUITest extends KernelTestBase { $this->installEntitySchema('user'); $this->installEntitySchema('entity_test_enhanced'); $this->installSchema('system', 'router'); + $this->installConfig(['system']); $bundle = EnhancedEntityBundle::create([ 'id' => 'default',