You are here

function better_formats_element_info_alter in Better Formats 8

Same name and namespace in other branches
  1. 7 better_formats.module \better_formats_element_info_alter()

Implements hook_element_info_alter().

File

./better_formats.module, line 55
Enhances the core input format system by managing input format defaults and settings.

Code

function better_formats_element_info_alter(array &$types) {

  // Our process callback must run immediately after
  // TextFormat::processFormat().
  if (isset($types['text_format']) && isset($types['text_format']['#process'])) {
    $search_value = [
      'Drupal\\filter\\Element\\TextFormat',
      'processFormat',
    ];
    $key = array_search($search_value, $types['text_format']['#process']);
    if ($key !== FALSE) {
      $key++;
      array_splice($types['text_format']['#process'], $key, 0, 'better_formats_filter_process_format');
    }
    else {
      $types['text_format']['#process'][] = 'better_formats_filter_process_format';
    }
  }
}