|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Cdf\BiCoreBundle\Twig\Extension; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
6
|
|
|
|
|
7
|
|
|
class UtilitaExtension extends \Twig_Extension |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* {@inheritdoc} |
|
11
|
|
|
*/ |
|
12
|
|
|
protected $container; |
|
13
|
|
|
|
|
14
|
19 |
|
public function __construct(ContainerInterface $container) |
|
15
|
|
|
{ |
|
16
|
19 |
|
$this->container = $container; |
|
17
|
19 |
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function getFunctions() |
|
20
|
|
|
{ |
|
21
|
|
|
return array( |
|
22
|
|
|
new \Twig_SimpleFunction('json_decode', array($this, 'jsonDecode', 'is_safe' => array('html'))), |
|
23
|
|
|
new \Twig_SimpleFunction('db2data', array($this, 'getDb2data', 'is_safe' => array('html'))), |
|
24
|
|
|
new \Twig_SimpleFunction('remote_file_exists', array($this, 'remoteFileExists', 'is_safe' => array('html'))), |
|
25
|
|
|
new \Twig_SimpleFunction('serviceExists', array($this, 'serviceExists')), |
|
26
|
|
|
new \Twig_SimpleFunction('getParameter', array($this, 'getParameter')), |
|
27
|
|
|
); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function getParameter($parameter) |
|
31
|
|
|
{ |
|
32
|
|
|
if ($this->container->hasParameter($parameter)) { |
|
33
|
|
|
return $this->container->getParameter($parameter); |
|
34
|
|
|
} else { |
|
35
|
|
|
return ''; |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function serviceExists($service) |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->container->has($service); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function getDb2data($giorno) |
|
45
|
|
|
{ |
|
46
|
|
|
// highlight_string highlights php code only if '<?php' tag is present. |
|
47
|
|
|
|
|
48
|
|
|
return FiUtilita::db2data($giorno, true); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
6 |
|
public function jsonDecode($string) |
|
51
|
|
|
{ |
|
52
|
6 |
|
return json_decode($string); |
|
53
|
|
|
} |
|
54
|
|
|
/** |
|
55
|
|
|
* @param string $url |
|
56
|
|
|
* |
|
57
|
|
|
* @return bool |
|
58
|
|
|
*/ |
|
59
|
|
|
public function remoteFileExists($url) |
|
60
|
|
|
{ |
|
61
|
|
|
$ch = curl_init($url); |
|
62
|
|
|
curl_setopt($ch, CURLOPT_NOBODY, true); |
|
63
|
|
|
curl_exec($ch); |
|
64
|
|
|
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
65
|
|
|
curl_close($ch); |
|
66
|
|
|
return $status === 200 ? true : false; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
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