summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-07-15 09:27:07 (GMT)
committerAlex Pott2014-07-15 09:27:07 (GMT)
commit5106b55d3403bb5410eb5524c2327e9c03b931bd (patch)
tree8a5cf6d40d7fb0a135f6abfe184468d21a14d0cd
parent0cf2996a30bf52025a0b06e395dbcb87cb56cb67 (diff)
Issue #2086499 by phiit, tim.plunkett | Gábor Hojtsy: Convert two page callbacks in language_elements_test.module to the new controller system.
-rw-r--r--core/modules/language/tests/language_elements_test/language_elements_test.module41
-rw-r--r--core/modules/language/tests/language_elements_test/language_elements_test.routing.yml4
-rw-r--r--core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php51
-rw-r--r--core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php40
-rw-r--r--core/modules/language/tests/language_elements_test/src/Form/LanguageElementsTestForm.php34
5 files changed, 93 insertions, 77 deletions
diff --git a/core/modules/language/tests/language_elements_test/language_elements_test.module b/core/modules/language/tests/language_elements_test/language_elements_test.module
deleted file mode 100644
index a85b7f3..0000000
--- a/core/modules/language/tests/language_elements_test/language_elements_test.module
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-/**
- * @file
- * Mock module for language form elements test.
- */
-
-/**
- * A form containing a language configuration element.
- */
-function language_elements_configuration_element() {
- $conf = language_get_default_configuration('some_custom_type', 'some_bundle');
-
- $form['lang_configuration'] = array(
- '#type' => 'language_configuration',
- '#entity_information' => array(
- 'entity_type' => 'some_custom_type',
- 'bundle' => 'some_bundle',
- ),
- '#default_value' => $conf,
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => 'Save',
- );
- $form['#submit'][] = 'language_configuration_element_submit';
- return $form;
-}
-
-/**
- * A form containing a language select element.
- */
-function language_elements_configuration_element_test() {
- $form['langcode'] = array(
- '#title' => t('Language select'),
- '#type' => 'language_select',
- '#default_value' => language_get_default_langcode('custom_type', 'some_bundle'),
- );
- return $form;
-}
diff --git a/core/modules/language/tests/language_elements_test/language_elements_test.routing.yml b/core/modules/language/tests/language_elements_test/language_elements_test.routing.yml
index 5a5698c..168bfbe 100644
--- a/core/modules/language/tests/language_elements_test/language_elements_test.routing.yml
+++ b/core/modules/language/tests/language_elements_test/language_elements_test.routing.yml
@@ -1,7 +1,7 @@
language_elements_test.config_element:
path: '/language-tests/language_configuration_element'
defaults:
- _content: '\Drupal\language_elements_test\Form\LanguageElementsTestForm::configFormElement'
+ _form: '\Drupal\language_elements_test\Form\LanguageConfigurationElement'
_title: 'Language configuration form element'
requirements:
_access: 'TRUE'
@@ -9,7 +9,7 @@ language_elements_test.config_element:
language_elements_test.config_element_test:
path: '/language-tests/language_configuration_element_test'
defaults:
- _content: '\Drupal\language_elements_test\Form\LanguageElementsTestForm::configFormElementTest'
+ _form: '\Drupal\language_elements_test\Form\LanguageConfigurationElementTest'
_title: 'Language configuration form element'
requirements:
_access: 'TRUE'
diff --git a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php
new file mode 100644
index 0000000..a213d5c
--- /dev/null
+++ b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * @file
+ * Contains \Drupal\language_elements_test\Form\LanguageConfigurationElement.
+ */
+
+namespace Drupal\language_elements_test\Form;
+
+use Drupal\Core\Form\FormBase;
+
+/**
+ * A form containing a language configuration element.
+ */
+class LanguageConfigurationElement extends FormBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormID() {
+ return 'language_elements_configuration_element';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function buildForm(array $form, array &$form_state) {
+ $conf = language_get_default_configuration('some_custom_type', 'some_bundle');
+
+ $form['lang_configuration'] = array(
+ '#type' => 'language_configuration',
+ '#entity_information' => array(
+ 'entity_type' => 'some_custom_type',
+ 'bundle' => 'some_bundle',
+ ),
+ '#default_value' => $conf,
+ );
+
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => 'Save',
+ );
+ $form['#submit'][] = 'language_configuration_element_submit';
+ return $form;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, array &$form_state) {
+ }
+}
diff --git a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php
new file mode 100644
index 0000000..bf53149
--- /dev/null
+++ b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * @file
+ * Contains \Drupal\language_elements_test\Form\LanguageConfigurationElementTest.
+ */
+
+namespace Drupal\language_elements_test\Form;
+
+use Drupal\Core\Form\FormBase;
+
+/**
+ * A form containing a language select element.
+ */
+class LanguageConfigurationElementTest extends FormBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormID() {
+ return 'language_elements_configuration_element_test';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function buildForm(array $form, array &$form_state) {
+ $form['langcode'] = array(
+ '#title' => t('Language select'),
+ '#type' => 'language_select',
+ '#default_value' => language_get_default_langcode('custom_type', 'some_bundle'),
+ );
+ return $form;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, array &$form_state) {
+ }
+}
diff --git a/core/modules/language/tests/language_elements_test/src/Form/LanguageElementsTestForm.php b/core/modules/language/tests/language_elements_test/src/Form/LanguageElementsTestForm.php
deleted file mode 100644
index 010b472..0000000
--- a/core/modules/language/tests/language_elements_test/src/Form/LanguageElementsTestForm.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\language_elements_test\Form\LanguageElementsTestForm.
- */
-
-namespace Drupal\language_elements_test\Form;
-
-/**
- * Controller routines for language_elements_test routes.
- */
-class LanguageElementsTestForm {
-
- /**
- * Wraps language_elements_configuration_element().
- *
- * @todo Remove language_elements_configuration_element().
- */
- public function configFormElement() {
- return \Drupal::formBuilder()->getForm('language_elements_configuration_element');
- }
-
- /**
- * Wraps language_element_tests_configuration_element_test().
- *
- * @todo Remove language_element_tests_configuration_element_test().
- */
- public function configFormElementTest() {
- return \Drupal::formBuilder()->getForm('language_elements_configuration_element_test');
- }
-
-}
-