filter_test.module

Same filename in other branches
  1. 9 core/modules/filter/tests/filter_test/filter_test.module
  2. 8.9.x core/modules/filter/tests/filter_test/filter_test.module
  3. 10 core/modules/filter/tests/filter_test/filter_test.module
  4. 11.x core/modules/filter/tests/filter_test/filter_test.module

Test module for Filter module hooks and functions not used in core.

File

modules/simpletest/tests/filter_test.module

View source
<?php


/**
 * @file
 * Test module for Filter module hooks and functions not used in core.
 */

/**
 * Implements hook_filter_format_insert().
 */
function filter_test_filter_format_insert($format) {
    drupal_set_message('hook_filter_format_insert invoked.');
}

/**
 * Implements hook_filter_format_update().
 */
function filter_test_filter_format_update($format) {
    drupal_set_message('hook_filter_format_update invoked.');
}

/**
 * Implements hook_filter_format_disable().
 */
function filter_test_filter_format_disable($format) {
    drupal_set_message('hook_filter_format_disable invoked.');
}

/**
 * Implements hook_filter_info().
 */
function filter_test_filter_info() {
    $filters['filter_test_uncacheable'] = array(
        'title' => 'Uncacheable filter',
        'description' => 'Does nothing, but makes a text format uncacheable.',
        'cache' => FALSE,
    );
    $filters['filter_test_replace'] = array(
        'title' => 'Testing filter',
        'description' => 'Replaces all content with filter and text format information.',
        'process callback' => 'filter_test_replace',
    );
    return $filters;
}

/**
 * Implements callback_filter_process().
 *
 * Process handler for filter_test_replace filter.
 *
 * Replaces all text with filter and text format information.
 */
function filter_test_replace($text, $filter, $format, $langcode, $cache, $cache_id) {
    $text = array();
    $text[] = 'Filter: ' . $filter->title . ' (' . $filter->name . ')';
    $text[] = 'Format: ' . $format->name . ' (' . $format->format . ')';
    $text[] = 'Language: ' . $langcode;
    $text[] = 'Cache: ' . ($cache ? 'Enabled' : 'Disabled');
    if ($cache_id) {
        $text[] = 'Cache ID: ' . $cache_id;
    }
    return implode("<br />\n", $text);
}

Functions

Title Deprecated Summary
filter_test_filter_format_disable Implements hook_filter_format_disable().
filter_test_filter_format_insert Implements hook_filter_format_insert().
filter_test_filter_format_update Implements hook_filter_format_update().
filter_test_filter_info Implements hook_filter_info().
filter_test_replace Implements callback_filter_process().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.