editor_test.module 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @file
  4. * Helper module for the Text Editor tests.
  5. */
  6. use Drupal\filter\FilterFormatInterface;
  7. /**
  8. * Implements hook_editor_js_settings_alter().
  9. */
  10. function editor_test_editor_js_settings_alter(&$settings) {
  11. // Allow tests to enable or disable this alter hook.
  12. if (!\Drupal::state()->get('editor_test_js_settings_alter_enabled', FALSE)) {
  13. return;
  14. }
  15. if (isset($settings['editor']['formats']['full_html'])) {
  16. $settings['editor']['formats']['full_html']['editorSettings']['ponyModeEnabled'] = FALSE;
  17. }
  18. }
  19. /**
  20. * Implements hook_editor_xss_filter_alter().
  21. */
  22. function editor_test_editor_xss_filter_alter(&$editor_xss_filter_class, FilterFormatInterface $format, FilterFormatInterface $original_format = NULL) {
  23. // Allow tests to enable or disable this alter hook.
  24. if (!\Drupal::state()->get('editor_test_editor_xss_filter_alter_enabled', FALSE)) {
  25. return;
  26. }
  27. $filters = $format->filters()->getAll();
  28. if (isset($filters['filter_html']) && $filters['filter_html']->status) {
  29. $editor_xss_filter_class = '\Drupal\editor_test\EditorXssFilter\Insecure';
  30. }
  31. }
  32. /**
  33. * Implements hook_editor_info_alter().
  34. */
  35. function editor_test_editor_info_alter(&$items) {
  36. if (!\Drupal::state()->get('editor_test_give_me_a_trex_thanks', FALSE)) {
  37. unset($items['trex']);
  38. }
  39. }