1 | <?php |
||
12 | class FixTwigExpressionSubscriber extends AbstractTwigExpressionSubscriber |
||
13 | { |
||
14 | protected $placeholders = array(); |
||
15 | |||
16 | 25 | public function __construct($placeholder = array('twital', 'twital'), array $options = array()) |
|
17 | { |
||
18 | 25 | parent::__construct($placeholder, $options); |
|
19 | |||
20 | 25 | $this->regexes = array_merge($this->regexes, array( |
|
21 | 25 | 'placeholder' => '{( ?)(' . preg_quote($placeholder[0]) . '[a-z0-9]+?' . preg_quote($placeholder[1]) . ')}iu', |
|
22 | 25 | )); |
|
23 | 25 | } |
|
24 | |||
25 | 25 | public static function getSubscribedEvents() |
|
26 | { |
||
27 | return array( |
||
28 | 25 | CompilerEvents::PRE_LOAD => array('addPlaceholder', 128), |
|
29 | 25 | CompilerEvents::POST_DUMP => array('removePlaceholder', -128), |
|
30 | 25 | ); |
|
31 | } |
||
32 | |||
33 | /** |
||
34 | * |
||
35 | * @param SourceEvent $event |
||
36 | */ |
||
37 | 24 | public function addPlaceholder(SourceEvent $event) |
|
61 | |||
62 | /** |
||
63 | * |
||
64 | * @param SourceEvent $event |
||
65 | */ |
||
66 | 24 | public function removePlaceholder(SourceEvent $event) |
|
84 | } |
||
85 |