Add Wordfilter example in custom module in README.md

Created on 22 February 2023, over 2 years ago

Problem/Motivation

I wanted to use this great module in a custom module, but wasn't sure how to. So I looked in the code for clues ...

But then it dawned on me to simply use the feature of the module as "intended", as a filter. After that, it was easy as:

  1. Add some words in a Wordfilter configuration
  2. Adding the filter to a text format (in this example plain_text)
  3. Process my variable in question with the plain_text format, using the code below
$raw_string = "A string to remove some bad words from";
$cleaned_text = [
  '#type' => 'processed_text',
  '#text' => $raw_string,
  '#format' => 'plain_text',
];

Steps to reproduce

Try to figure out how to use Wordfilter in a custom module, and not finding documentation on it.

Proposed resolution

Add the simple example above in README.md?

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Closed: duplicate

Version

2.0

Component

Documentation

Created by

🇩🇰Denmark ressa Copenhagen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024