Skip to content

Commit 0fa250a

Browse files
committed
Add new DataTransformPlugin class
1 parent 43e2101 commit 0fa250a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace aleksip\DataTransformPlugin;
4+
5+
use PatternLab\Config;
6+
use PatternLab\Console;
7+
8+
class DataTransformPlugin
9+
{
10+
public static function isEnabled()
11+
{
12+
$enabled = Config::getOption('plugins.dataTransform.enabled');
13+
$enabled = (is_null($enabled) || (bool)$enabled);
14+
15+
if (!$enabled) {
16+
self::writeInfo('plugin is disabled');
17+
}
18+
19+
return $enabled;
20+
}
21+
22+
public static function isVerbose()
23+
{
24+
$verbose = Config::getOption('plugins.dataTransform.verbose');
25+
26+
return (!is_null($verbose) && (bool)$verbose);
27+
}
28+
29+
public static function writeInfo($line, $indent = false)
30+
{
31+
if (self::isVerbose()) {
32+
if (!$indent) {
33+
$line = '[data transform plugin] ' . $line;
34+
}
35+
Console::writeInfo($line, $indent);
36+
}
37+
}
38+
39+
public static function writeWarning($line, $indent = false)
40+
{
41+
if (!$indent) {
42+
$line = '[data transform plugin] ' . $line;
43+
}
44+
Console::writeWarning($line, $indent);
45+
}
46+
}

0 commit comments

Comments
 (0)