You are here

public function FilterMailchimpCampaign::process in Mailchimp 2.x

Same name and namespace in other branches
  1. 8 modules/mailchimp_campaign/src/Plugin/Filter/FilterMailchimpCampaign.php \Drupal\mailchimp_campaign\Plugin\Filter\FilterMailchimpCampaign::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/mailchimp_campaign/src/Plugin/Filter/FilterMailchimpCampaign.php, line 23

Class

FilterMailchimpCampaign
Provides a filter to add content to and convert URLs for Mailchimp campaigns.

Namespace

Drupal\mailchimp_campaign\Plugin\Filter

Code

public function process($text, $langcode) {
  $result = new FilterProcessResult($text);

  // Replace node macros with entity content.
  $pattern = '/\\[mailchimp_campaign\\|entity_type=(\\w+)\\|entity_id=(\\d+)\\|view_mode=(\\w+)\\]/s';
  $text = preg_replace_callback($pattern, [
    $this,
    'processCallback',
  ], $text);

  // Convert URL to absolute.
  $text = $this
    ->convertUrl($text);
  $result
    ->setProcessedText($text);
  return $result;
}