-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathRewriteReplacementsEvent.php
More file actions
48 lines (41 loc) · 1.22 KB
/
RewriteReplacementsEvent.php
File metadata and controls
48 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Thunder\Shortcode\Event;
use Thunder\Shortcode\Shortcode\ReplacedShortcode;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
/**
* This event is called after gathering shortcode handlers results and just
* before the REPLACE_SHORTCODES event to allow modification of replacements
* before applying them in the source text.
*
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
*/
final class RewriteReplacementsEvent
{
/** @var ReplacedShortcode[] */
private $replacements;
/** @var ReplacedShortcode[] */
private $rewritten = array();
/** @var bool */
private $called = false;
/** @param ReplacedShortcode[] $replacements */
public function __construct(array $replacements)
{
$this->replacements = $replacements;
}
/** @return ReplacedShortcode[] */
public function getReplacements()
{
$this->called = true;
return $this->replacements;
}
/** @return void */
public function addRewritten(ReplacedShortcode $replacement)
{
$this->rewritten[] = $replacement;
}
/** @return ReplacedShortcode[] */
public function getRewritten()
{
return $this->called ? $this->rewritten : $this->replacements;
}
}