function filter_fallback_format

Same name in other branches
  1. 7.x modules/filter/filter.module \filter_fallback_format()
  2. 9 core/modules/filter/filter.module \filter_fallback_format()
  3. 8.9.x core/modules/filter/filter.module \filter_fallback_format()
  4. 10 core/modules/filter/filter.module \filter_fallback_format()

Returns the ID of the fallback text format that all users have access to.

The fallback text format is a regular text format in every respect, except it does not participate in the filter permission system and cannot be disabled. It needs to exist because any user who has permission to create formatted content must always have at least one text format they can use.

Because the fallback format is available to all users, it should always be configured securely. For example, when the Filter module is installed, this format is initialized to output plain text. Installation profiles and site administrators have the freedom to configure it further.

Note that the fallback format is completely distinct from the default format, which differs per user and is simply the first format which that user has access to. The default and fallback formats are only guaranteed to be the same for users who do not have access to any other format; otherwise, the fallback format's weight determines its placement with respect to the user's other formats.

Any modules implementing a format deletion functionality must not delete this format.

Return value

string|null The ID of the fallback text format.

See also

hook_filter_format_disable()

filter_default_format()

7 calls to filter_fallback_format()
FilterAdminTest::testFilterAdmin in core/modules/filter/tests/src/Functional/FilterAdminTest.php
Tests filter administration functionality.
FilterFormatAccessTest::testFormatPermissions in core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php
Tests the Filter format access permissions functionality.
FilterFormatAccessTest::testFormatRoles in core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php
Tests if text format is available to a role.
FilterFormatAccessTest::testFormatWidgetPermissions in core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php
Tests editing a page using a disallowed text format.
FilterNoFormatTest::testCheckMarkupNoFormat in core/modules/filter/tests/src/Kernel/FilterNoFormatTest.php
Tests text without format.

... See full list

1 string reference to 'filter_fallback_format'
d7_filter_settings.yml in core/modules/filter/migrations/d7_filter_settings.yml
core/modules/filter/migrations/d7_filter_settings.yml

File

core/modules/filter/filter.module, line 184

Code

function filter_fallback_format() {
    // This variable is automatically set in the database for all installations
    // of Drupal. In the event that it gets disabled or deleted somehow, there
    // is no safe default to return, since we do not want to risk making an
    // existing (and potentially unsafe) text format on the site automatically
    // available to all users. Returning NULL at least guarantees that this
    // cannot happen.
    return \Drupal::config('filter.settings')->get('fallback_format');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.