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/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 306d6d0..de3a6b8 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -261,8 +261,9 @@ function taxonomy_menu() { ); $items['taxonomy/term/%taxonomy_term/edit'] = array( 'title' => 'Edit', - 'title callback' => 'taxonomy_term_title', + 'title callback' => 'entity_page_label', 'title arguments' => array(2), + 'route_name' => 'taxonomy_term_edit', 'type' => MENU_LOCAL_TASK, 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, 'weight' => 10, @@ -301,12 +302,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 0245c19..7d45ea0 100644 --- a/core/modules/taxonomy/taxonomy.routing.yml +++ b/core/modules/taxonomy/taxonomy.routing.yml @@ -33,6 +33,13 @@ taxonomy_vocabulary_add: requirements: _entity_create_access: 'taxonomy_vocabulary' +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 88e195d..54b34f6 100644 --- a/core/modules/user/lib/Drupal/user/ProfileFormController.php +++ b/core/modules/user/lib/Drupal/user/ProfileFormController.php @@ -2,27 +2,35 @@ /** * @file - * Definition of Drupal\user\ProfileFormController. + * Contains \Drupal\user\ProfileFormController. */ namespace Drupal\user; +use Drupal\Core\Cache\Cache; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\DependencyInjection\ContainerInterface; + /** * Form controller for the profile forms. */ class ProfileFormController extends AccountFormController { /** - * Overrides Drupal\Core\Entity\EntityFormController::actions(). + * {@inheritdoc} */ 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'] = $this->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; } @@ -37,9 +45,23 @@ public function save(array $form, array &$form_state) { // Clear the page cache because pages can contain usernames and/or profile // information: - cache_invalidate_tags(array('content' => TRUE)); + Cache::invalidateTags(array('content' => TRUE)); drupal_set_message($this->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->getRequest()->query; + if ($query->has('destination')) { + $destination = array('destination' => $query->get('destination')); + $query->remove('destination'); + } + // We redirect from user/%/edit to user/%/cancel to make the tabs disappear. + $form_state['redirect'] = array('user/' . $this->entity->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'