function _filter_tips

Same name and namespace in other branches
  1. 10 core/modules/filter/filter.module \_filter_tips()
  2. 9 core/modules/filter/filter.module \_filter_tips()
  3. 8.9.x core/modules/filter/filter.module \_filter_tips()
  4. 7.x modules/filter/filter.module \_filter_tips()
  5. main core/modules/filter/filter.module \_filter_tips()

Retrieves the filter tips.

Parameters

string $format_id: The ID of the text format for which to retrieve tips, or -1 to return tips for all formats accessible to the current user.

Return value

array An associative array of filtering tips, keyed by filter name. Each filtering tip is an associative array with elements:

  • tip: Tip text.
  • id: Filter ID.

Deprecated

in drupal:11.4.0 and is removed from drupal:12.0.0. There is no replacement.

See also

https://www.drupal.org/node/3566774

1 call to _filter_tips()
FilterController::filterTips in core/modules/filter/src/Controller/FilterController.php
Displays a page with long filter tips.

File

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

Code

function _filter_tips($format_id) : array {
  if (func_num_args() > 1) {
    @trigger_error('The $long argument to _filter_tips() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Only short tips are used. See https://www.drupal.org/node/3567879', E_USER_DEPRECATED);
  }
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3566774', E_USER_DEPRECATED);
  $formats = \Drupal::service(FilterFormatRepositoryInterface::class)->getFormatsForAccount(\Drupal::currentUser());
  $tips = [];
  // If only listing one format, extract it from the $formats array.
  if ($format_id != -1) {
    $formats = [
      $formats[$format_id],
    ];
  }
  foreach ($formats as $format) {
    foreach ($format->filters() as $name => $filter) {
      if ($filter->status) {
        $method = new \ReflectionMethod($filter, 'tips');
        if ($method->getNumberOfParameters() > 0) {
          @trigger_error(sprintf('The $long argument to %s::tips() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Only short tips are used. See https://www.drupal.org/node/3567879', $filter::class), E_USER_DEPRECATED);
          $tip = $filter->tips(func_num_args() > 1 ? func_get_arg(1) : FALSE);
        }
        else {
          $tip = $filter->tips();
        }
        if (isset($tip)) {
          $tips[$format->label()][$name] = [
            'tip' => [
              '#markup' => $tip,
            ],
            'id' => $name,
          ];
        }
      }
    }
  }
  return $tips;
}

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