fixed deprecated functions that were breaking revisions.

This commit is contained in:
naomi 2022-04-03 13:39:01 +01:00
parent 65fe65474e
commit 49ab81ca23
2 changed files with 10 additions and 8 deletions

View File

@ -25,8 +25,8 @@ class OCActorController extends ControllerBase implements ContainerInjectionInte
* An array suitable for drupal_render(). * An array suitable for drupal_render().
*/ */
public function revisionShow($oc_actor_revision) { public function revisionShow($oc_actor_revision) {
$oc_actor = $this->entityManager()->getStorage('oc_actor')->loadRevision($oc_actor_revision); $oc_actor = $this->entityTypeManager()->getStorage('oc_actor')->loadRevision($oc_actor_revision);
$view_builder = $this->entityManager()->getViewBuilder('oc_actor'); $view_builder = $this->entityTypeManager()->getViewBuilder('oc_actor');
return $view_builder->view($oc_actor); return $view_builder->view($oc_actor);
} }
@ -41,8 +41,9 @@ class OCActorController extends ControllerBase implements ContainerInjectionInte
* The page title. * The page title.
*/ */
public function revisionPageTitle($oc_actor_revision) { public function revisionPageTitle($oc_actor_revision) {
$oc_actor = $this->entityManager()->getStorage('oc_actor')->loadRevision($oc_actor_revision); $oc_actor = $this->entityTypeManager()->getStorage('oc_actor')->loadRevision($oc_actor_revision);
return $this->t('Revision of %title from %date', ['%title' => $oc_actor->label(), '%date' => format_date($oc_actor->getRevisionCreationTime())]); $date = \Drupal::service('date.formatter')->format($oc_actor->getRevisionCreationTime());
return $this->t('Revision of %title from %date', ['%title' => $oc_actor->label(), '%date' => $date]);
} }
/** /**
@ -60,7 +61,7 @@ class OCActorController extends ControllerBase implements ContainerInjectionInte
$langname = $oc_actor->language()->getName(); $langname = $oc_actor->language()->getName();
$languages = $oc_actor->getTranslationLanguages(); $languages = $oc_actor->getTranslationLanguages();
$has_translations = (count($languages) > 1); $has_translations = (count($languages) > 1);
$oc_actor_storage = $this->entityManager()->getStorage('oc_actor'); $oc_actor_storage = $this->entityTypeManager()->getStorage('oc_actor');
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_actor->label()]) : $this->t('Revisions for %title', ['%title' => $oc_actor->label()]); $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_actor->label()]) : $this->t('Revisions for %title', ['%title' => $oc_actor->label()]);
$header = [$this->t('Revision'), $this->t('Operations')]; $header = [$this->t('Revision'), $this->t('Operations')];
@ -88,10 +89,11 @@ class OCActorController extends ControllerBase implements ContainerInjectionInte
// Use revision link to link to revisions that are not active. // Use revision link to link to revisions that are not active.
$date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short'); $date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short');
if ($vid != $oc_actor->getRevisionId()) { if ($vid != $oc_actor->getRevisionId()) {
$link = $this->l($date, new Url('entity.oc_actor.revision', ['oc_actor' => $oc_actor->id(), 'oc_actor_revision' => $vid])); $url = new Url('entity.oc_actor.revision', ['oc_actor' => $oc_actor->id(), 'oc_actor_revision' => $vid]);
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
} }
else { else {
$link = $oc_actor->link($date); $link = $oc_actor->toLink($date)->toString();
} }
$row = []; $row = [];

View File

@ -59,7 +59,7 @@ class OCActorForm extends ContentEntityForm {
])); ]));
} }
// If you have unpublished the entity and you can't see unpublished entities, redirect to a more informative message than just "Access Denied". // If you have unpublished the entity and you can't see unpublished entities, redirect to a more informative message than just "Access Denied".
if (!$form_state->getValue('status')['value'] && !\Drupal::currentUser()->hasPermission('view unpublished actor entities')) { if (is_array($form_state->getValue('status')) && $form_state->getValue('status')['value'] == false && !\Drupal::currentUser()->hasPermission('view unpublished actor entities')) {
\Drupal::messenger()->addMessage($this->t('The record for "%label" is now unpublished & hidden from you.', [ \Drupal::messenger()->addMessage($this->t('The record for "%label" is now unpublished & hidden from you.', [
'%label' => $entity->label(), '%label' => $entity->label(),
])); ]));