You are here

function spamspan in SpamSpan filter 8.2

Same name and namespace in other branches
  1. 8 spamspan.module \spamspan()
  2. 5 spamspan.module \spamspan()
  3. 6 spamspan.module \spamspan()
  4. 7 spamspan.module \spamspan()

A simple utility function wrapping the main processing callback.

This function may be called by other modules and themes.

Parameters

string $text: Text, maybe containing email addresses.

array $settings: An associative array of settings to be applied.

Return value

string The input text with emails replaced by spans

3 calls to spamspan()
EmailSpamspanFormatter::viewElements in src/Plugin/Field/FieldFormatter/EmailSpamspanFormatter.php
Builds a renderable array for a field value.
SpamspanExtension::spamSpanFilter in src/TwigExtension/SpamspanExtension.php
Applying spamspan filter to the given string.
SpamspanTestForm::buildForm in src/Form/SpamspanTestForm.php
Form constructor.
4 string references to 'spamspan'
FilterSpamspanUnitTest::setUp in tests/src/Kernel/FilterSpamspanUnitTest.php
FilterSpamspanUnitTest::testSpamSpanFilter in tests/src/Kernel/FilterSpamspanUnitTest.php
Tests the align filter.
SpamspanExtension::getFilters in src/TwigExtension/SpamspanExtension.php
spamspan_theme in ./spamspan.module
Implements hook_theme().

File

./spamspan.module, line 48
Implements the spamspan technique for hiding email addresses from spambots.

Code

function spamspan($text = '', array $settings = []) {
  $plugin_manager = \Drupal::service('plugin.manager.filter');
  $configuration = $plugin_manager
    ->getDefinition('filter_spamspan');
  $configuration['settings'] = $settings + $configuration['settings'];
  $filter = $plugin_manager
    ->createInstance('filter_spamspan', $configuration);
  return $filter
    ->process($text, NULL)
    ->getProcessedText();
}