public function SoEmbedFilter::process in Simple oEmbed 8.2
Same name and namespace in other branches
- 8 src/Plugin/Filter/SoEmbedFilter.php \Drupal\soembed\Plugin\Filter\SoEmbedFilter::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/ SoEmbedFilter.php, line 131
Class
- SoEmbedFilter
- Provides a filter to embed media via oEmbed.
Namespace
Drupal\soembed\Plugin\FilterCode
public function process($text, $langcode) {
$lines = explode("\n", $text);
if (!empty($this->settings['soembed_replace_inline'])) {
$lines = preg_replace_callback('#([^"])(https?://[^\\s<]+)([^"])#', [
$this,
'embed',
], $lines);
}
else {
$lines = preg_replace_callback('#^(<p>)?(https?://\\S+?)(</p>)?$#', [
$this,
'embed',
], $lines);
}
$text = implode("\n", $lines);
return new FilterProcessResult($text);
}