1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace oliverde8\ComfyBundle\Resolver\Form; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use oliverde8\ComfyBundle\Model\ConfigInterface; |
7
|
|
|
use oliverde8\ComfyBundle\Resolver\FormTypeProviderInterface; |
8
|
|
|
use oliverde8\ComfyBundle\Resolver\ScopeResolverInterface; |
9
|
|
|
use Symfony\Component\Form\FormInterface; |
|
|
|
|
10
|
|
|
|
11
|
|
|
class SimpleFormProvider implements FormTypeProviderInterface |
12
|
|
|
{ |
13
|
|
|
protected $scopeResolver; |
14
|
|
|
|
15
|
|
|
/** @var string */ |
16
|
|
|
protected string $configType; |
17
|
|
|
|
18
|
|
|
/** @var string */ |
19
|
|
|
protected string $formType; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* SimpleFormProvider constructor. |
23
|
|
|
* |
24
|
|
|
* @param string $configType |
25
|
|
|
* @param string $formType |
26
|
|
|
*/ |
27
|
|
|
public function __construct(ScopeResolverInterface $scopeResolver, string $configType, string $formType) |
28
|
|
|
{ |
29
|
|
|
$this->scopeResolver = $scopeResolver; |
30
|
|
|
$this->configType = $configType; |
31
|
|
|
$this->formType = $formType; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @inheritdoc |
36
|
|
|
*/ |
37
|
|
|
public function addTypeToForm(string $name, ConfigInterface $config, FormInterface $formBuilder, string $scope) |
38
|
|
|
{ |
39
|
|
|
$formBuilder->add( |
40
|
|
|
$name, |
41
|
|
|
$this->formType, |
42
|
|
|
[ |
43
|
|
|
'label' => $config->getName(), |
44
|
|
|
'help' => $this->getHelpHtml($config, $scope), |
45
|
|
|
'data' => $config->get($scope), |
46
|
|
|
], |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @inheritdoc |
52
|
|
|
*/ |
53
|
|
|
public function formatData($data) |
54
|
|
|
{ |
55
|
|
|
// No formatting needed. |
56
|
|
|
return $data; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @inheritdoc |
61
|
|
|
*/ |
62
|
|
|
public function supports(ConfigInterface $config): bool |
63
|
|
|
{ |
64
|
|
|
return $config instanceof $this->configType; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get html for the help field. |
69
|
|
|
* |
70
|
|
|
* @param ConfigInterface $config |
71
|
|
|
* @param string|null $scope |
72
|
|
|
* @return string |
73
|
|
|
*/ |
74
|
|
|
protected function getHelpHtml(ConfigInterface $config, ?string $scope) |
75
|
|
|
{ |
76
|
|
|
$helpMessage = $config->getDescription(); |
77
|
|
|
|
78
|
|
|
if (!$config->doesInherit($scope)) { |
79
|
|
|
$helpMessage .= "</br><strong>Default Value</strong>: " . $config->getDefaultValue(); |
80
|
|
|
|
81
|
|
|
$parentScope = $this->scopeResolver->inherits($scope); |
82
|
|
|
if ($config->get($parentScope) != $config->getDefaultValue()) { |
83
|
|
|
$helpMessage .= "</br><strong>Parent Scope Value</strong>: " . json_encode($config->get($parentScope)); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return $helpMessage; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
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