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 94a1d49..64c6115 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -631,7 +631,10 @@ public function submitForm(array &$form, array &$form_state) { $destination = drupal_get_destination(); $destinations[] = $destination['destination']; unset($_GET['destination']); - $form_state['redirect'] = field_ui_get_destinations($destinations); + $path = array_shift($destinations); + $options = drupal_parse_url($path); + $options['query']['destinations'] = $destinations; + $form_state['redirect'] = array($options['path'], $options); } else { drupal_set_message(t('Your settings have been saved.')); 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 4803701..3d09a7d 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 @@ -7,49 +7,12 @@ namespace Drupal\field_ui\Form; -use Drupal\Core\Form\FormInterface; -use Drupal\Core\ControllerInterface; use Drupal\field\Plugin\Core\Entity\FieldInstance; -use Drupal\field\Plugin\Type\Widget\WidgetPluginManager; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a form for the field instance settings form. */ -class FieldInstanceEditForm implements FormInterface, ControllerInterface { - - /** - * The field instance being edited. - * - * @var \Drupal\field\Plugin\Core\Entity\FieldInstance - */ - protected $instance; - - /** - * The field widget plugin manager. - * - * @var \Drupal\field\Plugin\Type\Widget\WidgetPluginManager - */ - protected $widgetManager; - - /** - * Constructs a new FieldInstanceEditForm object. - * - * @param \Drupal\field\Plugin\Type\Widget\WidgetPluginManager $widget_manager - * The field widget plugin manager. - */ - public function __construct(WidgetPluginManager $widget_manager) { - $this->widgetManager = $widget_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.field.widget') - ); - } +class FieldInstanceEditForm extends FieldInstanceFormBase { /** * {@inheritdoc} @@ -62,7 +25,7 @@ public function getFormID() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state, FieldInstance $field_instance = NULL) { - $this->instance = $form_state['instance'] = $field_instance; + parent::buildForm($form, $form_state, $field_instance); $bundle = $this->instance['bundle']; $entity_type = $this->instance['entity_type']; @@ -216,7 +179,6 @@ public function validateForm(array &$form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - form_load_include($form_state, 'inc', 'field_ui', 'field_ui.admin'); $field = $form['#field']; $entity = $form['#entity']; @@ -243,7 +205,7 @@ public function submitForm(array &$form, array &$form_state) { drupal_set_message(t('Field %label is required and uses the "hidden" widget. You might want to configure a default value.', array('%label' => $this->instance['label'])), 'warning'); } - $form_state['redirect'] = field_ui_next_destination($this->instance['entity_type'], $this->instance['bundle']); + $form_state['redirect'] = $this->getNextDestination(); } /** diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceFormBase.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceFormBase.php new file mode 100644 index 0000000..1a5a203 --- /dev/null +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceFormBase.php @@ -0,0 +1,92 @@ +entityManager = $entity_manager; + $this->widgetManager = $widget_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('plugin.manager.entity'), + $container->get('plugin.manager.field.widget') + ); + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, array &$form_state, FieldInstance $field_instance = NULL) { + $this->instance = $form_state['instance'] = $field_instance; + form_load_include($form_state, 'inc', 'field_ui', 'field_ui.admin'); + } + + /** + * Returns the next redirect path in a multipage sequence. + * + * @return string|array + * Either the next path, or an array of redirect paths. + */ + protected function getNextDestination() { + $destinations = !empty($_REQUEST['destinations']) ? $_REQUEST['destinations'] : array(); + if (!empty($destinations)) { + unset($_REQUEST['destinations']); + $path = array_shift($destinations); + $options = drupal_parse_url($path); + if ($destinations) { + $options['query']['destinations'] = $destinations; + } + return array($options['path'], $options); + } + $admin_path = $this->entityManager->getAdminPath($this->instance->entity_type, $this->instance->bundle); + return $admin_path . '/fields'; + } + +} diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldWidgetTypeForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldWidgetTypeForm.php index b28083a..85095d0 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldWidgetTypeForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldWidgetTypeForm.php @@ -7,49 +7,12 @@ namespace Drupal\field_ui\Form; -use Drupal\Core\Form\FormInterface; -use Drupal\Core\ControllerInterface; use Drupal\field\Plugin\Core\Entity\FieldInstance; -use Drupal\field\Plugin\Type\Widget\WidgetPluginManager; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a form for the widget selection form. */ -class FieldWidgetTypeForm implements FormInterface, ControllerInterface { - - /** - * The field instance being edited. - * - * @var \Drupal\field\Plugin\Core\Entity\FieldInstance - */ - protected $instance; - - /** - * The field widget plugin manager. - * - * @var \Drupal\field\Plugin\Type\Widget\WidgetPluginManager - */ - protected $widgetManager; - - /** - * Constructs a new FieldWidgetTypeForm object. - * - * @param \Drupal\field\Plugin\Type\Widget\WidgetPluginManager $widget_manager - * The field widget plugin manager. - */ - public function __construct(WidgetPluginManager $widget_manager) { - $this->widgetManager = $widget_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.field.widget') - ); - } +class FieldWidgetTypeForm extends FieldInstanceFormBase { /** * {@inheritdoc} @@ -62,8 +25,8 @@ public function getFormID() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state, FieldInstance $field_instance = NULL) { - $this->instance = $form_state['instance'] = $field_instance; - form_load_include($form_state, 'inc', 'field_ui', 'field_ui.admin'); + parent::buildForm($form, $form_state, $field_instance); + drupal_set_title($this->instance['label']); $bundle = $this->instance['bundle']; @@ -132,7 +95,7 @@ public function submitForm(array &$form, array &$form_state) { drupal_set_message(t('There was a problem changing the widget for field %label.', array('%label' => $instance['label'])), 'error'); } - $form_state['redirect'] = field_ui_next_destination($entity_type, $bundle); + $form_state['redirect'] = $this->getNextDestination(); } }