@@ 65-70 (lines=6) @@ | ||
62 | ||
63 | $events = new EventContainer(); |
|
64 | $events->addListener(Events::REPLACE_SHORTCODES, function(ReplaceShortcodesEvent $event) { |
|
65 | $event->setResult(array_reduce(array_reverse($event->getReplacements()), function($state, ReplacedShortcode $r) { |
|
66 | $offset = $r->getOffset(); |
|
67 | $length = mb_strlen($r->getText()); |
|
68 | ||
69 | return mb_substr($state, 0, $offset).$r->getReplacement().mb_substr($state, $offset + $length); |
|
70 | }, $event->getText())); |
|
71 | }); |
|
72 | ||
73 | $processor = new Processor(new RegularParser(), $handlers); |
@@ 117-122 (lines=6) @@ | ||
114 | ||
115 | private function applyReplaces($text, array $replaces) |
|
116 | { |
|
117 | return array_reduce(array_reverse($replaces), function($state, ReplacedShortcode $s) { |
|
118 | $offset = $s->getOffset(); |
|
119 | $length = mb_strlen($s->getText()); |
|
120 | ||
121 | return mb_substr($state, 0, $offset).$s->getReplacement().mb_substr($state, $offset + $length); |
|
122 | }, $text); |
|
123 | } |
|
124 | ||
125 | private function processHandler(ParsedShortcodeInterface $parsed, ProcessorContext $context, $handler) |