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 f71a5e9..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,8 +20,7 @@ class FieldUI { * @return array * An array of redirect paths. */ - public static function getNextDestination() { - $request = \Drupal::request(); + public static function getNextDestination(Request $request) { $next_destination = array(); $destinations = $request->query->get('destinations'); if (!empty($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 eb59e0e..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,10 +257,9 @@ public function submitForm(array &$form, array &$form_state) { */ public function delete(array &$form, array &$form_state) { $destination = array(); - $request = \Drupal::request(); - if ($request->query->has('destination')) { + if ($this->request->query->has('destination')) { $destination = drupal_get_destination(); - $request->query->remove('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)); } @@ -337,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'; }