Skip to content

Commit b9900fc

Browse files
committed
Add support for enabling and disabling the plugin from config
1 parent c76b119 commit b9900fc

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,16 @@
2727
"php": ">=5.5.9",
2828
"pattern-lab/core": "^2.6.3",
2929
"pattern-lab/patternengine-twig": "^2.0.0"
30+
},
31+
"extra": {
32+
"patternlab": {
33+
"config": {
34+
"plugins": {
35+
"dataTransform": {
36+
"enabled": true
37+
}
38+
}
39+
}
40+
}
3041
}
3142
}

src/aleksip/DataTransformPlugin/PatternLabListener.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace aleksip\DataTransformPlugin;
44

55
use aleksip\DataTransformPlugin\Twig\PatternDataNodeVisitor;
6+
use PatternLab\Config;
67
use PatternLab\Listener;
78
use PatternLab\PatternEngine\Twig\TwigUtil;
89

@@ -21,6 +22,11 @@ public function __construct()
2122

2223
public function twigPatternLoaderCustomize()
2324
{
25+
$enabled = Config::getOption('plugins.dataTransform.enabled');
26+
if (!is_null($enabled) && !((bool)$enabled)) {
27+
return;
28+
}
29+
2430
$this->dt ?: $this->dt = new DataTransformer();
2531
$this->nv ?: $this->nv = new PatternDataNodeVisitor($this->dt);
2632

0 commit comments

Comments
 (0)