protected function EntityEmbedFilterTestBase::processText in Entity Embed 8
Processes text through the provided filters.
Parameters
string $text: The text string to be filtered.
string $langcode: The language code of the text to be filtered.
string[] $filter_ids: (optional) The filter plugin IDs to apply to the given text, in the order they are being requested to be executed.
Return value
\Drupal\filter\FilterProcessResult The filtered text, wrapped in a FilterProcessResult object, and possibly with associated assets, cacheability metadata and placeholders.
See also
\Drupal\filter\Element\ProcessedText::preRenderText()
4 calls to EntityEmbedFilterTestBase::processText()
- EntityEmbedFilterTest::testFilterIntegration in tests/
src/ Kernel/ EntityEmbedFilterTest.php - @covers \Drupal\filter\Plugin\Filter\FilterAlign @covers \Drupal\filter\Plugin\Filter\FilterCaption @dataProvider providerFilterIntegration
- EntityEmbedFilterTest::testOnlyDrupalEntityTagProcessed in tests/
src/ Kernel/ EntityEmbedFilterTest.php - Tests that only <drupal-entity> tags are processed.
- EntityEmbedFilterTestBase::applyFilter in tests/
src/ Kernel/ EntityEmbedFilterTestBase.php - Applies the `@Filter=entity_embed` filter to text, pipes to raw content.
- EntityEmbedFilterTranslationTest::testTranslationSelection in tests/
src/ Kernel/ EntityEmbedFilterTranslationTest.php - Tests that the expected embedded entity translation is selected.
File
- tests/
src/ Kernel/ EntityEmbedFilterTestBase.php, line 166
Class
- EntityEmbedFilterTestBase
- Base class for Entity Embed filter tests.
Namespace
Drupal\Tests\entity_embed\KernelCode
protected function processText($text, $langcode = 'und', array $filter_ids = [
'entity_embed',
]) {
$manager = $this->container
->get('plugin.manager.filter');
$bag = new FilterPluginCollection($manager, []);
$filters = [];
foreach ($filter_ids as $filter_id) {
$filters[] = $bag
->get($filter_id);
}
$render_context = new RenderContext();
/** @var \Drupal\filter\FilterProcessResult $filter_result */
$filter_result = $this->container
->get('renderer')
->executeInRenderContext($render_context, function () use ($text, $filters, $langcode) {
$metadata = new BubbleableMetadata();
foreach ($filters as $filter) {
/** @var \Drupal\filter\FilterProcessResult $result */
$result = $filter
->process($text, $langcode);
$metadata = $metadata
->merge($result);
$text = $result
->getProcessedText();
}
return (new FilterProcessResult($text))
->merge($metadata);
});
if (!$render_context
->isEmpty()) {
$filter_result = $filter_result
->merge($render_context
->pop());
}
return $filter_result;
}