You are here

public function XBBCodeFilter::tips in Extensible BBCode 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::tips()
  2. 8.2 src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::tips()

Generates a filter's tip.

A filter's tips should be informative and to the point. Short tips are preferably one-liners.

@todo Split into getSummaryItem() and buildGuidelines().

Parameters

bool $long: Whether this callback should return a short tip to display in a form (FALSE), or whether a more elaborate filter tips should be returned for template_preprocess_filter_tips() (TRUE).

Return value

string|null Translated text to display as a tip, or NULL if this filter has no tip.

Overrides FilterBase::tips

File

src/Plugin/Filter/XBBCodeFilter.php, line 195

Class

XBBCodeFilter
Provides a filter that converts BBCode to HTML.

Namespace

Drupal\xbbcode\Plugin\Filter

Code

public function tips($long = FALSE) : string {
  if ($long) {
    $output = $this->tags
      ->getTable();
    $output['#caption'] = $this
      ->t('You may use the following BBCode tags:');
  }
  else {
    $output = $this->tags
      ->getSummary();
    $output['#prefix'] = $this
      ->t('You may use the following BBCode tags:') . ' ';
  }
  $output['#cache']['tags'] = $this->cacheTags;

  // @todo Remove once FilterInterface::tips() is modernized.
  $output = \Drupal::service('renderer')
    ->render($output);
  return $output;
}