diff --git a/src/Controller/TrashDeleteController.php b/src/Controller/TrashDeleteController.php index f3971ed..16cbeb6 100644 --- a/src/Controller/TrashDeleteController.php +++ b/src/Controller/TrashDeleteController.php @@ -76,13 +76,13 @@ class TrashDeleteController extends ControllerBase { } /** - * Delete an entity. + * Move an entity to trash. * * @return \Symfony\Component\HttpFoundation\RedirectResponse|array * Returns the redirect response if the entity is moderateable, otherwise * the delete form of the entity. */ - public function entityDelete() { + public function trashEntity() { $parameters = $this->routeMatch->getParameters()->all(); $entities = array_filter($parameters, function ($parameter) { @@ -96,11 +96,16 @@ class TrashDeleteController extends ControllerBase { $entity->get('moderation_state')->target_id = 'archived'; if ($entity->save()) { - drupal_set_message(t('The @entity %label has been moved to the trash.', [ + drupal_set_message(t('The @entity %label has been moved to the trash. Undo', [ '@entity' => $entity->getEntityType() ->getLabel(), '%label' => $entity->label(), + ':undo-page' => Url::fromRoute('restore.form', [ + 'entity_type_id' => $entity->getEntityTypeId(), + 'entity_id' => $entity->id(), + ])->toString(), ])); + } return $this->redirect($this->getRedirectUrl($entity) diff --git a/src/Routing/TrashRouteSubscriber.php b/src/Routing/TrashRouteSubscriber.php index 63c0df5..483f921 100644 --- a/src/Routing/TrashRouteSubscriber.php +++ b/src/Routing/TrashRouteSubscriber.php @@ -49,7 +49,7 @@ class TrashRouteSubscriber extends RouteSubscriberBase { if (!empty($route)) { $defaults = $route->getDefaults(); unset($defaults['_entity_form']); - $defaults['_controller'] = '\Drupal\trash\Controller\TrashDeleteController::entityDelete'; + $defaults['_controller'] = '\Drupal\trash\Controller\TrashDeleteController::trashEntity'; $route->setDefaults($defaults); $route->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]); $route->setRequirement('_csrf_token', 'TRUE');