function MediaEmbedFilterTestBase::processText
Same name in other branches
- 9 core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTestBase::processText()
- 8.9.x core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTestBase::processText()
- 10 core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTestBase::processText()
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()
5 calls to MediaEmbedFilterTestBase::processText()
- MediaEmbedFilterTest::testFilterIntegration in core/
modules/ media/ tests/ src/ Kernel/ MediaEmbedFilterTest.php - @covers \Drupal\filter\Plugin\Filter\FilterAlign @covers \Drupal\filter\Plugin\Filter\FilterCaption @dataProvider providerFilterIntegration
- MediaEmbedFilterTest::testMissingEntityIndicator in core/
modules/ media/ tests/ src/ Kernel/ MediaEmbedFilterTest.php - Tests the indicator for missing entities.
- MediaEmbedFilterTest::testOnlyDrupalMediaTagProcessed in core/
modules/ media/ tests/ src/ Kernel/ MediaEmbedFilterTest.php - Tests that only <drupal-media> tags are processed.
- MediaEmbedFilterTestBase::applyFilter in core/
modules/ media/ tests/ src/ Kernel/ MediaEmbedFilterTestBase.php - Applies the `media_embed` filter to text, pipes to raw content.
- MediaEmbedFilterTranslationTest::testTranslationSelection in core/
modules/ media/ tests/ src/ Kernel/ MediaEmbedFilterTranslationTest.php - Tests that the expected embedded media entity translation is selected.
File
-
core/
modules/ media/ tests/ src/ Kernel/ MediaEmbedFilterTestBase.php, line 228
Class
- MediaEmbedFilterTestBase
- Base class for Media Embed filter tests.
Namespace
Drupal\Tests\media\KernelCode
protected function processText($text, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, array $filter_ids = [
'media_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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.