diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Form/TranslatableForm.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Form/TranslatableForm.php
new file mode 100644
index 0000000..403a909
--- /dev/null
+++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Form/TranslatableForm.php
@@ -0,0 +1,131 @@
+fieldInfo['translatable'] ? 'disable' : 'enable';
+ return t('Are you sure you want to %action translation for the %name field?',
+ array('%action' => $action, '%name' => $this->fieldName)
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getDescription() {
+ return t('By submitting this form these changes will apply to the %name field everywhere it is used.',
+ array('%name' => $this->fieldName)
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getCancelPath() {
+ return '';
+ }
+
+ /**
+ * {@inheritdoc}
+ * @param string $field_name
+ * The field name.
+ */
+ public function buildForm(array $form, array &$form_state, $field_name = NULL) {
+ $this->fieldName = $field_name;
+ $this->fieldInfo = Field::fieldInfo($field_name);
+
+ return parent::buildForm($form, $form_state);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, array &$form_state) {
+ // This is the current state that we want to reverse.
+ $translatable = $form_state['values']['translatable'];
+ if ($this->field['translatable'] !== $translatable) {
+ // Field translatability has changed since form creation, abort.
+ $t_args = array('%field_name');
+ $msg = $translatable ?
+ t('The field %field_name is already translatable. No change was performed.', $t_args):
+ t('The field %field_name is already untranslatable. No change was performed.', $t_args);
+ drupal_set_message($msg, 'warning');
+ return;
+ }
+
+ // If a field is untranslatable, it can have no data except under
+ // LANGUAGE_NOT_SPECIFIED. Thus we need a field to be translatable before we
+ // convert data to the entity language. Conversely we need to switch data
+ // back to LANGUAGE_NOT_SPECIFIED before making a field untranslatable lest
+ // we lose information.
+ $operations = array(
+ array(
+ 'translation_entity_translatable_batch', array(
+ !$translatable,
+ $this->fieldName,
+ ),
+ ),
+ array(
+ 'translation_entity_translatable_switch', array(
+ !$translatable,
+ $this->fieldName,
+ ),
+ ),
+ );
+ $operations = $translatable ? $operations : array_reverse($operations);
+
+ $t_args = array('%field' => $this->fieldName);
+ $title = !$translatable ? t('Enabling translation for the %field field', $t_args) : t('Disabling translation for the %field field', $t_args);
+
+ $batch = array(
+ 'title' => $title,
+ 'operations' => $operations,
+ 'finished' => 'translation_entity_translatable_batch_done',
+ 'file' => drupal_get_path('module', 'translation_entity') . '/translation_entity.admin.inc',
+ );
+
+ batch_set($batch);
+
+ }
+
+
+}
diff --git a/core/modules/translation_entity/translation_entity.admin.inc b/core/modules/translation_entity/translation_entity.admin.inc
index 8c184b5..e8a4dd5 100644
--- a/core/modules/translation_entity/translation_entity.admin.inc
+++ b/core/modules/translation_entity/translation_entity.admin.inc
@@ -364,87 +364,6 @@ function _translation_entity_update_field_translatability($settings) {
}
/**
- * Form constructor for the confirmation of translatability switching.
- */
-function translation_entity_translatable_form(array $form, array &$form_state, $field_name) {
- $field = field_info_field($field_name);
- $t_args = array('%name' => $field_name);
-
- $warning = t('By submitting this form these changes will apply to the %name field everywhere it is used.', $t_args);
- if ($field['translatable']) {
- $title = t('Are you sure you want to disable translation for the %name field?', $t_args);
- $warning .= "
" . t("All the existing translations of this field will be deleted.
This action cannot be undone.");
- }
- else {
- $title = t('Are you sure you want to enable translation for the %name field?', $t_args);
- }
-
- // We need to keep some information for later processing.
- $form_state['field'] = $field;
-
- // Store the 'translatable' status on the client side to prevent outdated form
- // submits from toggling translatability.
- $form['translatable'] = array(
- '#type' => 'hidden',
- '#default_value' => $field['translatable'],
- );
-
- return confirm_form($form, $title, '', $warning);
-}
-
-/**
- * Form submission handler for translation_entity_translatable_form().
- *
- * This submit handler maintains consistency between the translatability of an
- * entity and the language under which the field data is stored. When a field is
- * marked as translatable, all the data in
- * $entity->{field_name}[LANGUAGE_NOT_SPECIFIED] is moved to
- * $entity->{field_name}[$entity_language]. When a field is marked as
- * untranslatable the opposite process occurs. Note that marking a field as
- * untranslatable will cause all of its translations to be permanently removed,
- * with the exception of the one corresponding to the entity language.
- */
-function translation_entity_translatable_form_submit(array $form, array $form_state) {
- // This is the current state that we want to reverse.
- $translatable = $form_state['values']['translatable'];
- $field_name = $form_state['field']['field_name'];
- $field = field_info_field($field_name);
-
- if ($field['translatable'] !== $translatable) {
- // Field translatability has changed since form creation, abort.
- $t_args = array('%field_name');
- $msg = $translatable ?
- t('The field %field_name is already translatable. No change was performed.', $t_args):
- t('The field %field_name is already untranslatable. No change was performed.', $t_args);
- drupal_set_message($msg, 'warning');
- return;
- }
-
- // If a field is untranslatable, it can have no data except under
- // LANGUAGE_NOT_SPECIFIED. Thus we need a field to be translatable before we
- // convert data to the entity language. Conversely we need to switch data back
- // to LANGUAGE_NOT_SPECIFIED before making a field untranslatable lest we lose
- // information.
- $operations = array(
- array('translation_entity_translatable_batch', array(!$translatable, $field_name)),
- array('translation_entity_translatable_switch', array(!$translatable, $field_name)),
- );
- $operations = $translatable ? $operations : array_reverse($operations);
-
- $t_args = array('%field' => $field_name);
- $title = !$translatable ? t('Enabling translation for the %field field', $t_args) : t('Disabling translation for the %field field', $t_args);
-
- $batch = array(
- 'title' => $title,
- 'operations' => $operations,
- 'finished' => 'translation_entity_translatable_batch_done',
- 'file' => drupal_get_path('module', 'translation_entity') . '/translation_entity.admin.inc',
- );
-
- batch_set($batch);
-}
-
-/**
* Toggles translatability of the given field.
*
* This is called from a batch operation, but should only run once per field.
diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module
index 82bd66d..7100426 100644
--- a/core/modules/translation_entity/translation_entity.module
+++ b/core/modules/translation_entity/translation_entity.module
@@ -201,10 +201,7 @@ function translation_entity_menu() {
$items['admin/config/regional/translation_entity/translatable/%'] = array(
'title' => 'Confirm change in translatability.',
'description' => 'Confirm page for changing field translatability.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('translation_entity_translatable_form', 5),
- 'access arguments' => array('administer entity translation'),
- 'file' => 'translation_entity.admin.inc',
+ 'route_name' => 'translation_entity_translatable',
);
return $items;
diff --git a/core/modules/translation_entity/translation_entity.routing.yml b/core/modules/translation_entity/translation_entity.routing.yml
new file mode 100644
index 0000000..57bf81e
--- /dev/null
+++ b/core/modules/translation_entity/translation_entity.routing.yml
@@ -0,0 +1,6 @@
+translation_entity_translatable:
+ pattern: 'admin/config/regional/translation_entity/translatable/{field_name}'
+ defaults:
+ _form: 'Drupal\translation_entity\Form\TranslatableForm'
+ requirements:
+ _permission: 'administer entity translation'