diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php index d2208a1..ed02cd6 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -12,6 +12,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\field_ui\OverviewBase; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; use Drupal\field\Plugin\Core\Entity\Field; /** @@ -34,6 +35,13 @@ class FieldOverview extends OverviewBase { protected $moduleHandler; /** + * The current request. + * + * @var \Symfony\Component\HttpFoundation\Request + */ + protected $request; + + /** * Constructs a new FieldOverview. * * @param \Drupal\Core\Entity\EntityManager $entity_manager @@ -42,11 +50,14 @@ class FieldOverview extends OverviewBase { * The field type manager * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler to invoke hooks on. + * @param \Symfony\Component\HttpFoundation\Request $request + * The request object. */ - public function __construct(EntityManager $entity_manager, FieldTypePluginManager $field_type_manager, ModuleHandlerInterface $module_handler) { + public function __construct(EntityManager $entity_manager, FieldTypePluginManager $field_type_manager, ModuleHandlerInterface $module_handler, Request $request) { parent::__construct($entity_manager); $this->fieldTypeManager = $field_type_manager; $this->moduleHandler = $module_handler; + $this->request = $request; } /** @@ -56,7 +67,8 @@ public static function create(ContainerInterface $container) { return new static( $container->get('plugin.manager.entity'), $container->get('plugin.manager.entity.field.field_type'), - $container->get('module_handler') + $container->get('module_handler'), + $container->get('request') ); } @@ -472,7 +484,7 @@ public function submitForm(array &$form, array &$form_state) { if ($destinations) { $destination = drupal_get_destination(); $destinations[] = $destination['destination']; - unset($_GET['destination']); + $this->request->query->remove('destination'); $path = array_shift($destinations); $options = drupal_parse_url($path); $options['query']['destinations'] = $destinations; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldUI.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldUI.php index 6e4a6a2..6d268d8 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldUI.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldUI.php @@ -7,6 +7,8 @@ namespace Drupal\field_ui; +use Symfony\Component\HttpFoundation\Request; + /** * Static service container wrapper for Field UI. */ @@ -18,11 +20,11 @@ class FieldUI { * @return array * An array of redirect paths. */ - public static function getNextDestination() { + public static function getNextDestination(Request $request) { $next_destination = array(); - $destinations = !empty($_REQUEST['destinations']) ? $_REQUEST['destinations'] : array(); + $destinations = $request->query->get('destinations'); if (!empty($destinations)) { - unset($_REQUEST['destinations']); + $request->query->remove('destinations'); $path = array_shift($destinations); $options = drupal_parse_url($path); if ($destinations) { diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php index f40e32a..143c814 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php @@ -15,6 +15,7 @@ use Drupal\field\Field; use Drupal\field_ui\FieldUI; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Provides a form for the field settings edit page. @@ -36,6 +37,13 @@ class FieldEditForm implements FormInterface, ControllerInterface { protected $entityManager; /** + * The current request. + * + * @var \Symfony\Component\HttpFoundation\Request + */ + protected $request; + + /** * {@inheritdoc} */ public function getFormID() { @@ -64,8 +72,9 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, FieldInstanceInterface $field_instance = NULL) { + public function buildForm(array $form, array &$form_state, FieldInstanceInterface $field_instance = NULL, Request $request = NULL) { $this->instance = $form_state['instance'] = $field_instance; + $this->request = $request; $field = $this->instance->getField(); $form['#field'] = $field; @@ -183,7 +192,7 @@ public function submitForm(array &$form, array &$form_state) { try { $field->save(); drupal_set_message(t('Updated field %label field settings.', array('%label' => $this->instance->label()))); - $next_destination = FieldUI::getNextDestination(); + $next_destination = FieldUI::getNextDestination($this->request); if (empty($next_destination)) { $next_destination = $this->entityManager->getAdminPath($this->instance->entity_type, $this->instance->bundle) . '/fields'; } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php index 046e012..0d57fe2 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php @@ -53,6 +53,13 @@ class FieldInstanceEditForm implements FormInterface, ControllerInterface { protected $fieldTypeManager; /** + * The current request. + * + * @var \Symfony\Component\HttpFoundation\Request + */ + protected $request; + + /** * Constructs a new field instance form. * * @param \Drupal\Core\Entity\EntityManager $entity_manager @@ -89,8 +96,9 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, FieldInstanceInterface $field_instance = NULL) { + public function buildForm(array $form, array &$form_state, FieldInstanceInterface $field_instance = NULL, Request $request = NULL) { $this->instance = $form_state['instance'] = $field_instance; + $this->request = $request; $bundle = $this->instance['bundle']; $entity_type = $this->instance['entity_type']; @@ -249,9 +257,9 @@ public function submitForm(array &$form, array &$form_state) { */ public function delete(array &$form, array &$form_state) { $destination = array(); - if (isset($_GET['destination'])) { + if ($this->request->query->has('destination')) { $destination = drupal_get_destination(); - unset($_GET['destination']); + $this->request->query->remove('destination'); } $form_state['redirect'] = array('admin/structure/types/manage/' . $this->instance['bundle'] . '/fields/' . $this->instance->id() . '/delete', array('query' => $destination)); } @@ -336,7 +344,7 @@ protected function getFieldItem(EntityInterface $entity, $field_name) { * Either the next path, or an array of redirect paths. */ protected function getNextDestination() { - $next_destination = FieldUI::getNextDestination(); + $next_destination = FieldUI::getNextDestination($this->request); if (empty($next_destination)) { $next_destination = $this->entityManager->getAdminPath($this->instance->entity_type, $this->instance->bundle) . '/fields'; }