|
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\Adapters;
|
|
15
|
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------
|
|
17
|
|
|
|
|
18
|
|
|
use O2System\Parser\Template\Abstracts\AbstractAdapter;
|
|
19
|
|
|
use O2System\Spl\Exceptions\RuntimeException;
|
|
20
|
|
|
|
|
21
|
|
|
/**
|
|
22
|
|
|
* Class Mustache
|
|
23
|
|
|
*
|
|
24
|
|
|
* This class driver for Mustache Template Engine for O2System PHP Framework templating system.
|
|
25
|
|
|
*
|
|
26
|
|
|
* @package O2System\Parser\Template\Adapters
|
|
27
|
|
|
*/
|
|
28
|
|
|
class Mustache extends AbstractAdapter
|
|
29
|
|
|
{
|
|
30
|
|
|
/**
|
|
31
|
|
|
* Mustache::initialize
|
|
32
|
|
|
*
|
|
33
|
|
|
* @param array $config
|
|
34
|
|
|
*
|
|
35
|
|
|
* @return static
|
|
36
|
|
|
* @throws \O2System\Spl\Exceptions\RuntimeException
|
|
37
|
|
|
*/
|
|
38
|
|
|
public function initialize(array $config = [])
|
|
39
|
|
|
{
|
|
40
|
|
|
if (empty($this->engine)) {
|
|
41
|
|
|
if ($this->isSupported()) {
|
|
42
|
|
|
$this->engine = new \Mustache_Engine();
|
|
|
|
|
|
|
43
|
|
|
} else {
|
|
44
|
|
|
throw new RuntimeException(
|
|
45
|
|
|
'PARSER_E_THIRD_PARTY',
|
|
46
|
|
|
0,
|
|
47
|
|
|
['Mustache Template Engine by Justin Hileman', 'https://github.com/bobthecow']
|
|
48
|
|
|
);
|
|
49
|
|
|
}
|
|
50
|
|
|
}
|
|
51
|
|
|
|
|
52
|
|
|
return $this;
|
|
53
|
|
|
}
|
|
54
|
|
|
|
|
55
|
|
|
// ------------------------------------------------------------------------
|
|
56
|
|
|
|
|
57
|
|
|
/**
|
|
58
|
|
|
* Mustache::isSupported
|
|
59
|
|
|
*
|
|
60
|
|
|
* Checks if this template engine is supported on this system.
|
|
61
|
|
|
*
|
|
62
|
|
|
* @return bool
|
|
63
|
|
|
*/
|
|
64
|
|
|
public function isSupported()
|
|
65
|
|
|
{
|
|
66
|
|
|
if (class_exists('\Mustache_Engine')) {
|
|
67
|
|
|
return true;
|
|
68
|
|
|
}
|
|
69
|
|
|
|
|
70
|
|
|
return false;
|
|
71
|
|
|
}
|
|
72
|
|
|
|
|
73
|
|
|
// ------------------------------------------------------------------------
|
|
74
|
|
|
|
|
75
|
|
|
/**
|
|
76
|
|
|
* Mustache::parse
|
|
77
|
|
|
*
|
|
78
|
|
|
* @param array $vars Variable to be parsed.
|
|
79
|
|
|
*
|
|
80
|
|
|
* @return string
|
|
81
|
|
|
*/
|
|
82
|
|
|
public function parse(array $vars = [])
|
|
83
|
|
|
{
|
|
84
|
|
|
return $this->engine->render($this->string, $vars);
|
|
85
|
|
|
}
|
|
86
|
|
|
|
|
87
|
|
|
// ------------------------------------------------------------------------
|
|
88
|
|
|
|
|
89
|
|
|
/**
|
|
90
|
|
|
* Mustache::isValidEngine
|
|
91
|
|
|
*
|
|
92
|
|
|
* Checks if is a valid Object Engine.
|
|
93
|
|
|
*
|
|
94
|
|
|
* @param object $engine Engine Object Resource.
|
|
95
|
|
|
*
|
|
96
|
|
|
* @return bool
|
|
97
|
|
|
*/
|
|
98
|
|
|
protected function isValidEngine($engine)
|
|
99
|
|
|
{
|
|
100
|
|
|
if ($engine instanceof \Mustache_Engine) {
|
|
101
|
|
|
return true;
|
|
102
|
|
|
}
|
|
103
|
|
|
|
|
104
|
|
|
return false;
|
|
105
|
|
|
}
|
|
106
|
|
|
} |
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