diff --git a/core/modules/user/lib/Drupal/user/ProfileFormController.php b/core/modules/user/lib/Drupal/user/ProfileFormController.php index c10c226..3bab412 100644 --- a/core/modules/user/lib/Drupal/user/ProfileFormController.php +++ b/core/modules/user/lib/Drupal/user/ProfileFormController.php @@ -21,7 +21,7 @@ protected function actions(array $form, array &$form_state) { $element['delete']['#type'] = 'submit'; $element['delete']['#value'] = t('Cancel account'); - $element['delete']['#submit'] = array('user_edit_cancel_submit'); + $element['delete']['#submit'] = array(array($this, 'editCancelSubmit')); $element['delete']['#access'] = $account->id() > 1 && (($account->id() == $GLOBALS['user']->id() && user_access('cancel account')) || user_access('administer users')); return $element; @@ -41,4 +41,19 @@ public function save(array $form, array &$form_state) { drupal_set_message(t('The changes have been saved.')); } + + /** + * Submit method for the 'Cancel account' button. + */ + public function editCancelSubmit($form, &$form_state) { + $destination = array(); + $query = Drupal::request()->query; + if ($query->has('destination')) { + $destination = drupal_get_destination(); + $query->remove('destination'); + } + // Note: We redirect from user/uid/edit to user/uid/cancel to make the tabs disappear. + $account = $form_state['controller']->getEntity(); + $form_state['redirect'] = array("user/" . $account->id() . "/cancel", array('query' => $destination)); + } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 2c0e2d3..c498aa8 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -944,12 +944,8 @@ function user_menu() { ); $items['user/%user/edit'] = array( 'title' => 'Edit', - 'page callback' => 'entity_get_form', - 'page arguments' => array(1), - 'access callback' => 'entity_page_access', - 'access arguments' => array(1, 'update'), + 'route_name' => 'user_edit', 'type' => MENU_LOCAL_TASK, - 'file' => 'user.pages.inc', ); return $items; } diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index 2aa9b88..deb4d5e 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -119,21 +119,6 @@ function template_preprocess_user(&$variables) { } /** - * Submit function for the 'Cancel account' button on the user edit form. - */ -function user_edit_cancel_submit($form, &$form_state) { - $destination = array(); - $query = Drupal::request()->query; - if ($query->has('destination')) { - $destination = drupal_get_destination(); - $query->remove('destination'); - } - // Note: We redirect from user/uid/edit to user/uid/cancel to make the tabs disappear. - $account = $form_state['controller']->getEntity(); - $form_state['redirect'] = array("user/" . $account->id() . "/cancel", array('query' => $destination)); -} - -/** * Form builder; confirm form for cancelling user account. * * @ingroup forms diff --git a/core/modules/user/user.routing.yml b/core/modules/user/user.routing.yml index 90570ea..547c770 100644 --- a/core/modules/user/user.routing.yml +++ b/core/modules/user/user.routing.yml @@ -102,3 +102,10 @@ user_login: _form: '\Drupal\user\Form\UserLoginForm' requirements: _access: 'TRUE' + +user_edit: + pattern: '/user/{user}/edit' + defaults: + _entity_form: 'user.default' + requirements: + _entity_access: 'user.update'