public function GutenbergFilter::process in Gutenberg 8.2
Overrides FilterInterface::process
See also
https://github.com/WordPress/gutenberg/blob/master/post-content.php
File
- src/
Plugin/ Filter/ GutenbergFilter.php, line 104
Class
- GutenbergFilter
- Provides a filter for Gutenberg blocks.
Namespace
Drupal\gutenberg\Plugin\FilterCode
public function process($text, $langcode) {
$result = new FilterProcessResult($text);
$this
->setProviderSettings();
// Use a bubbleable metadata.
$bubbleable_metadata = new BubbleableMetadata();
$block_parser = new BlockParser();
$blocks = $block_parser
->parse($text);
$output = '';
foreach ($blocks as $block) {
$output .= $this
->renderBlock($block, $bubbleable_metadata);
}
$result
->setProcessedText($output);
// Add the module/theme libraries.
$this
->addAttachments($result);
// Add the processed blocks bubbleable metadata.
$result
->addCacheableDependency($bubbleable_metadata);
return $result;
}