diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index e5321d4..6d4223d 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -197,17 +197,13 @@ function aggregator_menu() { ); $items['aggregator/sources/%aggregator_feed/configure'] = array( 'title' => 'Configure', - 'page callback' => 'entity_get_form', - 'page arguments' => array(2), - 'access arguments' => array('administer news feeds'), + 'route_name' => 'aggregator_feed_configure', 'type' => MENU_LOCAL_TASK, 'weight' => 10, ); $items['admin/config/services/aggregator/edit/feed/%aggregator_feed'] = array( 'title' => 'Edit feed', - 'page callback' => 'entity_get_form', - 'page arguments' => array(6), - 'access arguments' => array('administer news feeds'), + 'route_name' => 'aggregator_feed_edit', ); $items['admin/config/services/aggregator/delete/feed/%aggregator_feed'] = array( 'title' => 'Delete feed', diff --git a/core/modules/aggregator/aggregator.routing.yml b/core/modules/aggregator/aggregator.routing.yml index cadbb14..e2c72c3 100644 --- a/core/modules/aggregator/aggregator.routing.yml +++ b/core/modules/aggregator/aggregator.routing.yml @@ -33,6 +33,20 @@ aggregator_feed_add: requirements: _permission: 'administer news feeds' +aggregator_feed_configure: + pattern: 'aggregator/sources/{aggregator_feed}/configure' + defaults: + _entity_form: 'aggregator_feed.default' + requirements: + _permission: 'administer news feeds' + +aggregator_feed_edit: + pattern: 'admin/config/services/aggregator/edit/feed/{aggregator_feed}' + defaults: + _entity_form: 'aggregator_feed.default' + requirements: + _permission: 'administer news feeds' + aggregator_feed_refresh: pattern: '/admin/config/services/aggregator/update/{aggregator_feed}' defaults: diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 99ab62e..2195b55 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -348,11 +348,6 @@ function testTermInterface() { // Check that the term feed page is working. $this->drupalGet('taxonomy/term/' . $term->id() . '/feed'); - // Check that the term edit page does not try to interpret additional path - // components as arguments for entity_get_form(). - $this->drupalGet('taxonomy/term/' . $term->id() . '/edit/' . $this->randomName()); - $this->assertResponse(200, 'The taxonomy term edit menu item ensured appropriate arguments were passed to its page callback.'); - // Delete the term. $this->drupalPost('taxonomy/term/' . $term->id() . '/edit', array(), t('Delete')); $this->drupalPost(NULL, NULL, t('Delete')); diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 0bfa84d..2e091c4 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -265,14 +265,10 @@ function taxonomy_menu() { ); $items['taxonomy/term/%taxonomy_term/edit'] = array( 'title' => 'Edit', - 'page callback' => 'entity_get_form', - 'page arguments' => array(2, 'default', array()), - 'access callback' => 'entity_page_access', - 'access arguments' => array(2, 'update'), + 'route_name' => 'taxonomy_term_edit', 'type' => MENU_LOCAL_TASK, 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, 'weight' => 10, - 'file' => 'taxonomy.admin.inc', ); $items['taxonomy/term/%taxonomy_term/delete'] = array( 'title' => 'Delete', @@ -316,12 +312,8 @@ function taxonomy_menu() { ); $items['admin/structure/taxonomy/manage/%taxonomy_vocabulary/edit'] = array( 'title' => 'Edit', - 'page callback' => 'entity_get_form', - 'page arguments' => array(4), - 'access callback' => 'entity_page_access', - 'access arguments' => array(4, 'update'), + 'route_name' => 'taxonomy_vocabulary_edit', 'type' => MENU_LOCAL_TASK, - 'file' => 'taxonomy.admin.inc', ); $items['admin/structure/taxonomy/%taxonomy_vocabulary/delete'] = array( 'title' => 'Delete', diff --git a/core/modules/taxonomy/taxonomy.routing.yml b/core/modules/taxonomy/taxonomy.routing.yml index 09dc6d0..8a3d21f 100644 --- a/core/modules/taxonomy/taxonomy.routing.yml +++ b/core/modules/taxonomy/taxonomy.routing.yml @@ -12,6 +12,13 @@ taxonomy_term_add: requirements: _access_taxonomy_term_create: 'taxonomy_term' +taxonomy_term_edit: + pattern: 'taxonomy/term/{taxonomy_term}/edit' + defaults: + _entity_form: 'taxonomy_term.default' + requirements: + _entity_access: 'taxonomy_term.update' + taxonomy_term_delete: pattern: '/taxonomy/term/{taxonomy_term}/delete' defaults: @@ -19,6 +26,13 @@ taxonomy_term_delete: requirements: _entity_access: 'taxonomy_term.delete' +taxonomy_vocabulary_edit: + pattern: 'admin/structure/taxonomy/manage/{taxonomy_vocabulary}/edit' + defaults: + _entity_form: 'taxonomy_vocabulary.default' + requirements: + _entity_access: 'taxonomy_vocabulary.update' + taxonomy_vocabulary_delete: pattern: '/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/delete' defaults: diff --git a/core/modules/user/lib/Drupal/user/ProfileFormController.php b/core/modules/user/lib/Drupal/user/ProfileFormController.php index c10c226..adee645 100644 --- a/core/modules/user/lib/Drupal/user/ProfileFormController.php +++ b/core/modules/user/lib/Drupal/user/ProfileFormController.php @@ -7,6 +7,10 @@ namespace Drupal\user; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Session\AccountInterface; + /** * Form controller for the profile forms. */ @@ -17,12 +21,17 @@ class ProfileFormController extends AccountFormController { */ protected function actions(array $form, array &$form_state) { $element = parent::actions($form, $form_state); + + // The user account being edited. $account = $this->entity; + // The user doing the editing. + $user = $this->getCurrentUser(); + $element['delete']['#type'] = 'submit'; $element['delete']['#value'] = t('Cancel account'); - $element['delete']['#submit'] = array('user_edit_cancel_submit'); - $element['delete']['#access'] = $account->id() > 1 && (($account->id() == $GLOBALS['user']->id() && user_access('cancel account')) || user_access('administer users')); + $element['delete']['#submit'] = array(array($this, 'editCancelSubmit')); + $element['delete']['#access'] = $account->id() > 1 && (($account->id() == $user->id() && $user->hasPermission('cancel account')) || $user->hasPermission('administer users')); return $element; } @@ -41,4 +50,19 @@ public function save(array $form, array &$form_state) { drupal_set_message(t('The changes have been saved.')); } + + /** + * Provides a submit handler for the 'Cancel account' button. + */ + public function editCancelSubmit($form, &$form_state) { + $destination = array(); + $query = $this->request->query; + if ($query->has('destination')) { + $destination = array('destination' => $query->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']->entity; + $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 62ccfd6..a3a2fec 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 4d8c195..18343bc 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'