Skip to content

Instantly share code, notes, and snippets.

@pfaocle
Created January 27, 2016 16:59
Show Gist options
  • Save pfaocle/8256875edf826ec98eec to your computer and use it in GitHub Desktop.
Save pfaocle/8256875edf826ec98eec to your computer and use it in GitHub Desktop.
Remove null filters from migrated D8 text formats
<?php
use Drupal\filter\Plugin\Filter\FilterNull;
/**
* Run on migrated text formats which have "missing" or null filters.
*
* @see \Drupal\filter\FilterFormatFormBase::form()
*/
function _update_text_formats() {
foreach (filter_formats() as $format) {
$filters = $format->filters();
foreach ($filters as $filter_id => $filter) {
if ($filter instanceof FilterNull) {
$filters->removeInstanceID($filter_id);
}
}
$format->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment