|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the O2System Framework package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Steeve Andrian Salim |
|
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
// ------------------------------------------------------------------------ |
|
13
|
|
|
|
|
14
|
|
|
namespace O2System\Parser\Template; |
|
15
|
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------ |
|
17
|
|
|
|
|
18
|
|
|
use O2System\Spl\Patterns\Structural\Provider\AbstractProvider; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class Collection |
|
22
|
|
|
* @package O2System\Parser\TemplateEngines |
|
23
|
|
|
*/ |
|
24
|
|
|
class Collection extends AbstractProvider |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Collection::$supportedAdapters |
|
28
|
|
|
* |
|
29
|
|
|
* @var array |
|
30
|
|
|
*/ |
|
31
|
|
|
public $supportedAdapters = [ |
|
32
|
|
|
|
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
// ------------------------------------------------------------------------ |
|
36
|
|
|
|
|
37
|
|
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
|
|
if ($handle = opendir(__DIR__ . DIRECTORY_SEPARATOR . 'Adapters')) { |
|
40
|
|
|
|
|
41
|
|
|
while (false !== ($file = readdir($handle))) { |
|
42
|
|
|
|
|
43
|
|
|
if ($file != "." && $file != "..") { |
|
44
|
|
|
array_push($this->supportedAdapters, pathinfo($file, PATHINFO_FILENAME)); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
closedir($handle); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
if ($handle = opendir(__DIR__ . DIRECTORY_SEPARATOR . 'Engines')) { |
|
52
|
|
|
|
|
53
|
|
|
while (false !== ($file = readdir($handle))) { |
|
54
|
|
|
|
|
55
|
|
|
if ($file != "." && $file != "..") { |
|
56
|
|
|
array_push($this->supportedAdapters, pathinfo($file, PATHINFO_FILENAME)); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
closedir($handle); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
// ------------------------------------------------------------------------ |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Collection::load |
|
68
|
|
|
* |
|
69
|
|
|
* @param string $engine |
|
70
|
|
|
* @param array $config |
|
71
|
|
|
* |
|
72
|
|
|
* @return bool |
|
73
|
|
|
*/ |
|
74
|
|
|
public function load($engine, array $config = []) |
|
75
|
|
|
{ |
|
76
|
|
|
if (class_exists($adapter = '\O2System\Parser\Template\Adapters\\' . $engine)) { |
|
77
|
|
|
|
|
78
|
|
|
$this->register((new $adapter())->setConfig($config), $adapter); |
|
79
|
|
|
|
|
80
|
|
|
return $this->__isset($adapter); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return false; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
// ------------------------------------------------------------------------ |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Collection::parse |
|
90
|
|
|
* |
|
91
|
|
|
* @param string $string |
|
92
|
|
|
* @param array $vars |
|
93
|
|
|
* |
|
94
|
|
|
* @return string |
|
95
|
|
|
*/ |
|
96
|
|
|
public function parse($string, array $vars = []) |
|
97
|
|
|
{ |
|
98
|
|
|
$output = $string; |
|
99
|
|
|
|
|
100
|
|
|
if(is_file($string)) { |
|
101
|
|
|
$output = file_get_contents($string); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
if($this->count()) { |
|
105
|
|
|
foreach($this->registry as $adapter) { |
|
106
|
|
|
if($adapter instanceof Abstracts\AbstractAdapter) { |
|
107
|
|
|
if($adapter->isSupported()) { |
|
108
|
|
|
$adapter->initialize(); |
|
109
|
|
|
$adapter->loadString($output); |
|
110
|
|
|
$output = $adapter->parse($vars); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
return $output; |
|
117
|
|
|
} |
|
118
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths