public function BlockFilter::process in Gutenberg 8
Process each URL.
Overrides FilterInterface::process
File
- src/
Plugin/ Filter/ BlockFilter.php, line 65
Class
- BlockFilter
- Class BlockFilter.
Namespace
Drupal\gutenberg\Plugin\FilterCode
public function process($text, $langcode) {
$lines = explode("\n", $text);
$lines = preg_replace_callback('#<!-- wp:drupalblock\\/.*\\s(\\{.*\\})\\s\\/-->#', [
$this,
'renderBlock',
], $lines);
$text = implode("\n", $lines);
$result = new FilterProcessResult($text);
// Add cache metadata from Drupal blocks.
$metadata = $this
->cacheabilityMetadata($text);
$result
->setCacheTags($metadata['tags']);
$result
->setCacheContexts($metadata['contexts']);
$result
->setCacheMaxAge($metadata['max-age']);
return $result;
}