config_translation_test.module 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * @file
  4. * Configuration Translation Test module.
  5. */
  6. use Drupal\Core\Extension\Extension;
  7. use Drupal\Core\Form\FormStateInterface;
  8. /**
  9. * Implements hook_system_info_alter().
  10. */
  11. function config_translation_test_system_info_alter(array &$info, Extension $file, $type) {
  12. // @see \Drupal\config_translation\Tests\ConfigTranslationUiThemeTest
  13. if ($file->getType() == 'theme' && $file->getName() == 'config_translation_test_theme') {
  14. $info['hidden'] = FALSE;
  15. }
  16. }
  17. /**
  18. * Implements hook_entity_type_alter().
  19. */
  20. function config_translation_test_entity_type_alter(array &$entity_types) {
  21. // Remove entity definition for these entity types from config_test module.
  22. unset($entity_types['config_test_no_status']);
  23. unset($entity_types['config_query_test']);
  24. }
  25. /**
  26. * Implements hook_config_translation_info_alter().
  27. */
  28. function config_translation_test_config_translation_info_alter(&$info) {
  29. if (\Drupal::state()->get('config_translation_test_config_translation_info_alter')) {
  30. // Limit account settings config files to only one of them.
  31. $info['entity.user.admin_form']['names'] = ['user.settings'];
  32. // Add one more config file to the site information page.
  33. $info['system.site_information_settings']['names'][] = 'system.rss';
  34. }
  35. }
  36. /**
  37. * Implements hook_form_BASE_FORM_ID_alter() for ConfigTranslationFormBase.
  38. *
  39. * Adds a list of configuration names to the top of the configuration
  40. * translation form.
  41. *
  42. * @see \Drupal\config_translation\Form\ConfigTranslationFormBase
  43. */
  44. function config_translation_test_form_config_translation_form_alter(&$form, FormStateInterface $form_state) {
  45. if (\Drupal::state()->get('config_translation_test_alter_form_alter')) {
  46. $form['#base_altered'] = TRUE;
  47. }
  48. }
  49. /**
  50. * Implements hook_form_FORM_ID_alter() for ConfigTranslationAddForm.
  51. *
  52. * Changes the title to include the source language.
  53. *
  54. * @see \Drupal\config_translation\Form\ConfigTranslationAddForm
  55. */
  56. function config_translation_test_form_config_translation_add_form_alter(&$form, FormStateInterface $form_state) {
  57. if (\Drupal::state()->get('config_translation_test_alter_form_alter')) {
  58. $form['#altered'] = TRUE;
  59. }
  60. }
  61. /**
  62. * Implements hook_form_FORM_ID_alter() for ConfigTranslationEditForm.
  63. *
  64. * Adds a column to the configuration translation edit form that shows the
  65. * current translation. Note that this column would not be displayed by default,
  66. * as the columns are hardcoded in
  67. * config_translation_manage_form_element.html.twig. The template would need to
  68. * be overridden for the column to be displayed.
  69. *
  70. * @see \Drupal\config_translation\Form\ConfigTranslationEditForm
  71. */
  72. function config_translation_test_form_config_translation_edit_form_alter(&$form, FormStateInterface $form_state) {
  73. if (\Drupal::state()->get('config_translation_test_alter_form_alter')) {
  74. $form['#altered'] = TRUE;
  75. }
  76. }