Skip to content
Snippets Groups Projects
Verified Commit 883e240e authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3454196 by james.williams, longwave: Filter placeholders without...

Issue #3454196 by james.williams, longwave: Filter placeholders without arguments are not replaced when HTML corrector filter applied afterwards

(cherry picked from commit dc89b84c)
parent c082ee7e
No related branches found
No related tags found
11 merge requests!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8949Backport .gitlabci.yml changes.,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #230823 passed with warnings
Pipeline: drupal

#230872

    Pipeline: drupal

    #230869

      Pipeline: drupal

      #230865

        +6
        ......@@ -136,7 +136,11 @@ public function createPlaceholder($callback, array $args) {
        // @see \Drupal\Core\Render\PlaceholderGenerator::createPlaceholder()
        $arguments = UrlHelper::buildQuery($args);
        $token = Crypt::hashBase64(serialize([$callback, $args]));
        $placeholder_markup = '<drupal-filter-placeholder callback="' . Html::escape($callback) . '" arguments="' . Html::escape($arguments) . '" token="' . Html::escape($token) . '"></drupal-filter-placeholder>';
        $placeholder_markup = '<drupal-filter-placeholder callback="' . Html::escape($callback) . '"';
        if ($arguments !== '') {
        $placeholder_markup .= ' arguments="' . Html::escape($arguments) . '"';
        }
        $placeholder_markup .= ' token="' . Html::escape($token) . '"></drupal-filter-placeholder>';
        // Add the placeholder attachment.
        $this->addAttachments([
        ......
        ......@@ -16,7 +16,7 @@
        #[Filter(
        id: "filter_test_placeholders",
        title: new TranslatableMarkup("Testing filter"),
        description: new TranslatableMarkup("Appends a placeholder to the content; associates #lazy_builder callback."),
        description: new TranslatableMarkup("Appends placeholders to the content; associates #lazy_builder callbacks."),
        type: FilterInterface::TYPE_TRANSFORM_REVERSIBLE
        )]
        class FilterTestPlaceholders extends FilterBase implements TrustedCallbackInterface {
        ......@@ -26,8 +26,9 @@ class FilterTestPlaceholders extends FilterBase implements TrustedCallbackInterf
        */
        public function process($text, $langcode) {
        $result = new FilterProcessResult($text);
        $placeholder = $result->createPlaceholder('\Drupal\filter_test\Plugin\Filter\FilterTestPlaceholders::renderDynamicThing', ['llama']);
        $result->setProcessedText($text . '<p>' . $placeholder . '</p>');
        $placeholder_with_argument = $result->createPlaceholder('\Drupal\filter_test\Plugin\Filter\FilterTestPlaceholders::renderDynamicThing', ['llama']);
        $placeholder_without_arguments = $result->createPlaceholder('\Drupal\filter_test\Plugin\Filter\FilterTestPlaceholders::renderStaticThing', []);
        $result->setProcessedText($text . '<p>' . $placeholder_with_argument . '</p>' . '<p>' . $placeholder_without_arguments . '</p>');
        return $result;
        }
        ......@@ -46,11 +47,26 @@ public static function renderDynamicThing($thing) {
        ];
        }
        /**
        * #lazy_builder callback; builds a render array.
        *
        * @return array
        * A renderable array.
        */
        public static function renderStaticThing(): array {
        return [
        '#markup' => 'This is a static llama.',
        ];
        }
        /**
        * {@inheritdoc}
        */
        public static function trustedCallbacks() {
        return ['renderDynamicThing'];
        return [
        'renderDynamicThing',
        'renderStaticThing',
        ];
        }
        }
        ......@@ -318,7 +318,7 @@ public function testProcessedTextElement(): void {
        'user.permissions',
        ];
        $this->assertEqualsCanonicalizing($expected_cache_contexts, $build['#cache']['contexts'], 'Expected cache contexts present.');
        $expected_markup = '<p>Hello, world!</p><p>This is a dynamic llama.</p>';
        $expected_markup = '<p>Hello, world!</p><p>This is a dynamic llama.</p><p>This is a static llama.</p>';
        $this->assertSame($expected_markup, (string) $build['#markup'], 'Expected #lazy_builder callback has been applied.');
        }
        ......
        ......@@ -58,7 +58,7 @@ protected function getExpectedNormalizedEntity() {
        [
        'value' => 'Cádiz is the oldest continuously inhabited city in Spain and a nice place to spend a Sunday with friends.',
        'format' => 'my_text_format',
        'processed' => '<p>Cádiz is the oldest continuously inhabited city in Spain and a nice place to spend a Sunday with friends.</p>' . "\n" . '<p>This is a dynamic llama.</p>',
        'processed' => '<p>Cádiz is the oldest continuously inhabited city in Spain and a nice place to spend a Sunday with friends.</p>' . "\n" . '<p>This is a dynamic llama.</p><p>This is a static llama.</p>',
        ],
        ];
        return $expected;
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment