Commit 5106b55d authored by alexpott's avatar alexpott

Issue #2086499 by phiit, tim.plunkett | Gábor Hojtsy: Convert two page...

Issue #2086499 by phiit, tim.plunkett | Gábor Hojtsy: Convert two page callbacks in language_elements_test.module to the new controller system.
parent 0cf2996a
<?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;
}
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'
<?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) {
}
}
<?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) {
}
}
<?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');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment