Skip to content
Snippets Groups Projects
Commit abfa4916 authored by Sascha Grossenbacher's avatar Sascha Grossenbacher
Browse files

Fixes for RevisionBasicUITest

parent 80644f80
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ use Drupal\Core\Controller\ControllerBase; ...@@ -13,6 +13,7 @@ use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\RevisionLogInterface; use Drupal\Core\Entity\RevisionLogInterface;
use Drupal\user\EntityOwnerInterface; use Drupal\user\EntityOwnerInterface;
...@@ -35,21 +36,29 @@ class RevisionOverviewController extends ControllerBase { ...@@ -35,21 +36,29 @@ class RevisionOverviewController extends ControllerBase {
*/ */
protected $dateFormatter; protected $dateFormatter;
/**
* The renderer.
*
* @var \Drupal\Core\Render\RendererInterface
*/
protected $renderer;
/** /**
* Creates a new RevisionOverviewController instance. * Creates a new RevisionOverviewController instance.
* *
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter. * The date formatter.
*/ */
public function __construct(DateFormatterInterface $date_formatter) { public function __construct(DateFormatterInterface $date_formatter, RendererInterface $renderer) {
$this->dateFormatter = $date_formatter; $this->dateFormatter = $date_formatter;
$this->renderer = $renderer;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function create(ContainerInterface $container) { 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 { ...@@ -106,10 +115,12 @@ class RevisionOverviewController extends ControllerBase {
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short'); $date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
$link = $revision->toLink($date, 'revision'); $link = $revision->toLink($date, 'revision');
// @todo: Simplify this when https://www.drupal.org/node/2334319 lands.
$username = [ $username = [
'#theme' => 'username', '#theme' => 'username',
'#account' => $revision->getRevisionUser(), '#account' => $revision->getRevisionUser(),
]; ];
$username = $this->renderer->render($username);
} }
else { else {
$link = $revision->toLink($revision->label(), 'revision'); $link = $revision->toLink($revision->label(), 'revision');
......
...@@ -74,7 +74,7 @@ class RevisionRevertForm extends ConfirmFormBase { ...@@ -74,7 +74,7 @@ class RevisionRevertForm extends ConfirmFormBase {
*/ */
public function getQuestion() { public function getQuestion() {
if ($this->revision instanceof RevisionLogInterface) { 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?'); return $this->t('Are you sure you want to revert the revision?');
} }
......
...@@ -33,6 +33,7 @@ class RevisionBasicUITest extends KernelTestBase { ...@@ -33,6 +33,7 @@ class RevisionBasicUITest extends KernelTestBase {
$this->installEntitySchema('user'); $this->installEntitySchema('user');
$this->installEntitySchema('entity_test_enhanced'); $this->installEntitySchema('entity_test_enhanced');
$this->installSchema('system', 'router'); $this->installSchema('system', 'router');
$this->installConfig(['system']);
$bundle = EnhancedEntityBundle::create([ $bundle = EnhancedEntityBundle::create([
'id' => 'default', 'id' => 'default',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment