File tree Expand file tree Collapse file tree 4 files changed +45
-0
lines changed
Adapters/CommonMark/Transformers Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Phiki \Adapters \CommonMark \Transformers ;
4+
5+ use Phiki \Contracts \RequiresGrammarInterface ;
6+ use Phiki \Transformers \AbstractTransformer ;
7+ use Phiki \Transformers \Concerns \RequiresGrammar ;
8+
9+ class AnnotationsTransformer extends AbstractTransformer implements RequiresGrammarInterface
10+ {
11+ use RequiresGrammar;
12+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Phiki \Contracts ;
4+
5+ use Phiki \Grammar \ParsedGrammar ;
6+
7+ interface RequiresGrammarInterface
8+ {
9+ /**
10+ * Set the parsed grammar for the transformer.
11+ */
12+ public function withGrammar (ParsedGrammar $ grammar ): void ;
13+ }
Original file line number Diff line number Diff line change 33namespace Phiki \Output \Html ;
44
55use Closure ;
6+ use Phiki \Contracts \RequiresGrammarInterface ;
67use Phiki \Contracts \TransformerInterface ;
78use Phiki \Grammar \ParsedGrammar ;
89use Phiki \Phast \ClassList ;
@@ -173,6 +174,10 @@ public function __toString(): string
173174
174175 foreach ($ this ->transformers as $ transformer ) {
175176 $ transformer ->withMeta ($ this ->meta );
177+
178+ if ($ transformer instanceof RequiresGrammarInterface) {
179+ $ transformer ->withGrammar ($ this ->grammar );
180+ }
176181 }
177182
178183 [$ code ] = $ this ->callTransformerMethod ('preprocess ' , $ this ->code );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Phiki \Transformers \Concerns ;
4+
5+ use Phiki \Grammar \ParsedGrammar ;
6+
7+ trait RequiresGrammar
8+ {
9+ protected ParsedGrammar $ grammar ;
10+
11+ public function withGrammar (ParsedGrammar $ grammar ): void
12+ {
13+ $ this ->grammar = $ grammar ;
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments