Skip to content

Commit a9a1f65

Browse files
committed
Make correct use of event handler to remove paragraph tags (Case 89286)
1 parent aa36209 commit a9a1f65

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

Resources/config/shortcodes.xml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77

88
<!-- Definition of a Shortcode HandlerContainer instance. -->
99
<service id="webfactory.shortcode.handler_container" class="Thunder\Shortcode\HandlerContainer\HandlerContainer">
10-
<!-- Event handler that removes <p>...</p> tag that directly wrap shortcodes. -->
11-
<call method="add">
12-
<argument type="constant">\Thunder\Shortcode\Events::REPLACE_SHORTCODES</argument>
13-
<argument type="service">
14-
<service class="Webfactory\ShortcodeBundle\Handler\RemoveWrappingParagraphElementsEventHandler"/>
15-
</argument>
16-
</call>
1710
</service>
1811

1912
<!-- Definition of a Shortcode RegularParser instance. -->
@@ -26,6 +19,17 @@
2619
<argument type="service" id="webfactory.shortcode.handler_container" />
2720
</service>
2821

22+
<!-- Definition of a Shortcode EventContainer instance. -->
23+
<service id="webfactory.shortcode.event_container" class="Thunder\Shortcode\EventContainer\EventContainer">
24+
<!-- Event handler that removes <p>...</p> tag that directly wrap shortcodes. -->
25+
<call method="addListener">
26+
<argument type="constant">\Thunder\Shortcode\Events::REPLACE_SHORTCODES</argument>
27+
<argument type="service">
28+
<service class="Webfactory\ShortcodeBundle\Handler\RemoveWrappingParagraphElementsEventHandler"/>
29+
</argument>
30+
</call>
31+
</service>
32+
2933
<!-- Base definition for the EmbedForShortcodeHandler with esi renderer. -->
3034
<service abstract="true" id="webfactory.shortcode.embed_esi_for_shortcode_handler" class="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler" lazy="true">
3135
<argument type="service" id="fragment.handler"/>
@@ -47,6 +51,7 @@
4751
<!-- Twig extension providing the |shortcodes filter. The content will be passed to the Shortcode Processor. -->
4852
<service id="Webfactory\ShortcodeBundle\Twig\ShortcodeExtension" class="Webfactory\ShortcodeBundle\Twig\ShortcodeExtension">
4953
<argument type="service" id="webfactory.shortcode.processor"/>
54+
<argument type="service" id="webfactory.shortcode.event_container"/>
5055
<tag name="twig.extension"/>
5156
</service>
5257

Twig/ShortcodeExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Webfactory\ShortcodeBundle\Twig;
44

5+
use Thunder\Shortcode\EventContainer\EventContainer;
56
use Thunder\Shortcode\Processor\Processor;
67
use Twig\Extension\AbstractExtension;
78
use Twig\TwigFilter;
@@ -17,9 +18,9 @@ final class ShortcodeExtension extends AbstractExtension
1718
/**
1819
* @param Processor $processor
1920
*/
20-
public function __construct(Processor $processor)
21+
public function __construct(Processor $processor, EventContainer $eventContainer)
2122
{
22-
$this->processor = $processor->withMaxIterations(null);
23+
$this->processor = $processor->withMaxIterations(null)->withEventContainer($eventContainer);
2324
}
2425

2526
public function getFilters()

0 commit comments

Comments
 (0)