0

Suppose I have a text format like full_html and I have an enabled filter with ID my_filter_id.

How can I disable the filter programmatically from full_html.

I needed to put this in an update hook.

Hopefully its a one-liner.

1 Answer 1

0

I did find a solution thought it wasn't a one liner. This will remove the filter from all text formats.

use Drupal\filter\Entity\FilterFormat; function MYMODULE_update_10000(&$sandbox) { $filters = filter_formats(); foreach ($filters as $name => $filter) { /* @var $filter Drupal\filter\Entity\FilterFormat */ // Instantiate the filter collection prior to removing the filters to // avoid fatal errors. $filter->filters(); $filter->removeFilter('my_filter_id'); $filter->save(); } } 

I found the solution from Drupal.org

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.