// Ensure 'filter.settings' cacheability is respected.
CacheableMetadata::
createFromRenderArray($element) ->
addCacheableDependency($filter_settings) ->
applyTo($element);
} /** @var \Drupal\filter\Entity\FilterFormat $format **/
$format = FilterFormat::
load($format_id);
// If the requested text format doesn't exist or its disabled, the text
// cannot be filtered.
if (!
$format || !
$format->
status()) { $message = !
$format ? 'Missing text format: %format.' : 'Disabled text format: %format.';
static::
logger('filter'
)->
alert($message,
['%format' =>
$format_id]);
$element['#markup'
] = '';
return $element;
} $filter_must_be_applied =
function DFilterInterface
$filter) use ($filter_types_to_skip) { $enabled =
$filter->status === TRUE;
$type =
$filter->
getType();
// Prevent FilterInterface::TYPE_HTML_RESTRICTOR from being skipped.
$filter_type_must_be_applied =
$type == FilterInterface::TYPE_HTML_RESTRICTOR || !
in_array($type,
$filter_types_to_skip);
return $enabled &&
$filter_type_must_be_applied;
};