By claudiu.cristea on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.4.x
Introduced in version:
11.4.0
Issue links:
Description:
There's a new service Drupal\filter\FilterFormatRepositoryInterface accomplishing the functionality of formats. filter_formats(), filter_formats_reset(), filter_get_formats_by_role(), filter_default_format() & filter_fallback_format() which now are deprecated and will be removed in Drupal 13.
| Before | After |
|---|---|
filter_formats() |
$repository->getAllFormats() |
filter_formats(User::load(123)) |
$repository->getFormatsForAccount(User::load(123)) |
|
FilterFormat::load('basic_html')->getRoles() |
filter_get_formats_by_role('moderator') |
$repository->getFormatsByRole('moderator') |
filter_default_format(User::load(123)) |
$repository->getDefaultFormat(User::load(123)->id() |
filter_fallback_format() |
$repository->getFallbackFormatId() |
filter_formats_reset() |
Note: This is rarely if ever needed. The new memory caches are automatically invalidated if formats change and browser tests also reset memory caches on POST requests. Before updating the calls, it is recommended to first test if it works without it. |
Other changes:
- The
filter_formatentity is exposing a new method\Drupal\filter\FilterFormatInterface::getRoles(), which returns a list of roles that are allowed for this text format. - The constructor \Drupal\filter\FilterFormatListBuilder requires now injecting the new
Drupal\filter\FilterFormatRepositoryInterfaceservice as the 5th parameter. - Passing
'filter_formats'string todrupal_static_reset()is also deprecated.
Impacts:
Module developers
Site templates, recipes and distribution developers