You are here

public function FilterInlineSms::process in SMS Framework 2.1.x

Same name and namespace in other branches
  1. 8 modules/sms_sendtophone/src/Plugin/Filter/FilterInlineSms.php \Drupal\sms_sendtophone\Plugin\Filter\FilterInlineSms::process()
  2. 2.x modules/sms_sendtophone/src/Plugin/Filter/FilterInlineSms.php \Drupal\sms_sendtophone\Plugin\Filter\FilterInlineSms::process()

Performs the filter processing.

Parameters

string $text: The text string to be filtered.

string $langcode: The language code of the text to be filtered.

Return value

\Drupal\filter\FilterProcessResult The filtered text, wrapped in a FilterProcessResult object, and possibly with associated assets, cacheability metadata and placeholders.

Overrides FilterInterface::process

See also

\Drupal\filter\FilterProcessResult

File

modules/sms_sendtophone/src/Plugin/Filter/FilterInlineSms.php, line 34

Class

FilterInlineSms
Provides a filter to align elements.

Namespace

Drupal\sms_sendtophone\Plugin\Filter

Code

public function process($text, $langcode) {
  $matches = [];
  preg_match_all('/\\[sms\\](.*?)\\[\\/sms\\]/i', $text, $matches, PREG_SET_ORDER);
  $type = $this->settings['display'] == 'icon' ? 'icon' : 'text';
  foreach ($matches as $match) {
    $text = str_replace($match[0], $this
      ->theme($match[1], $type), $text);
  }
  return new FilterProcessResult($text);
}