You are here

public function PhotosFilter::process in Album Photos 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/Filter/PhotosFilter.php \Drupal\photos\Plugin\Filter\PhotosFilter::process()
  2. 6.0.x src/Plugin/Filter/PhotosFilter.php \Drupal\photos\Plugin\Filter\PhotosFilter::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

src/Plugin/Filter/PhotosFilter.php, line 23

Class

PhotosFilter
Provides a filter to embed image and albums from the photos module.

Namespace

Drupal\photos\Plugin\Filter

Code

public function process($text, $langcode) {
  $result = new FilterProcessResult($text);
  $text = ' ' . $text . ' ';
  $text = preg_replace_callback('/\\[photos=(.*?)\\](.*?)\\[\\/photos\\]/ms', '_photos_filter_process', $text);
  $text = mb_substr($text, 1, -1);
  $result
    ->setProcessedText($text);
  return $result;
}