Created
January 27, 2016 16:59
-
-
Save pfaocle/8256875edf826ec98eec to your computer and use it in GitHub Desktop.
Remove null filters from migrated D8 text formats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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