Commit d4da27e5 authored by webchick's avatar webchick

Issue #1987692 by becw, cbiggins, tim.plunkett | vijaycs85: Convert all...

Issue #1987692 by becw, cbiggins, tim.plunkett | vijaycs85: Convert all references to entity_get_form() as page callbacks to _entity_form() w/ corresponding routing.yml entries.
parent abfc89fb
......@@ -191,17 +191,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',
......
......@@ -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:
......
......@@ -262,8 +262,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,
......@@ -298,10 +299,7 @@ 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,
);
$items['admin/structure/taxonomy/%taxonomy_vocabulary/delete'] = array(
......
......@@ -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:
......
......@@ -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));
}
}
......@@ -929,12 +929,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;
}
......
......@@ -118,21 +118,6 @@ function template_preprocess_user(&$variables) {
$variables['attributes']['class'][] = 'profile';
}
/**
* 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.
*
......
......@@ -109,3 +109,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'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment