|
1
|
|
|
<?php |
|
2
|
|
|
namespace Mezon\Application; |
|
3
|
|
|
|
|
4
|
|
|
use Mezon\HtmlTemplate\HtmlTemplate; |
|
5
|
|
|
|
|
6
|
|
|
class ActionBuilder |
|
7
|
|
|
{ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Ignore config keyu |
|
11
|
|
|
* |
|
12
|
|
|
* @return callable factory method |
|
13
|
|
|
*/ |
|
14
|
|
|
public static function ignoreKey(): callable |
|
15
|
|
|
{ |
|
16
|
|
|
return function (): void { |
|
17
|
|
|
// do nothind |
|
18
|
|
|
}; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Method resets layout |
|
23
|
|
|
* |
|
24
|
|
|
* @param $template template |
|
|
|
|
|
|
25
|
|
|
* @param string $value |
|
26
|
|
|
* new layout |
|
27
|
|
|
* @return callable factory method |
|
28
|
|
|
*/ |
|
29
|
|
|
public static function resetLayout(HtmlTemplate $template, string $value): callable |
|
30
|
|
|
{ |
|
31
|
|
|
return function () use ($template, $value) { |
|
32
|
|
|
$template->resetLayout($value); |
|
33
|
|
|
}; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Overriding defined config |
|
38
|
|
|
* |
|
39
|
|
|
* @param string $path |
|
40
|
|
|
* path to the current config |
|
41
|
|
|
* @param array $config |
|
42
|
|
|
* config itself |
|
43
|
|
|
*/ |
|
44
|
|
|
public static function constructOverrideHandler(string $path, array &$config): void |
|
45
|
|
|
{ |
|
46
|
|
|
if (isset($config['override'])) { |
|
47
|
|
|
|
|
48
|
|
|
$path = pathinfo($path, PATHINFO_DIRNAME); |
|
49
|
|
|
|
|
50
|
|
|
$baseConfig = json_decode(file_get_contents($path . '/' . $config['override']), true); |
|
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
$config = array_merge($baseConfig, $config); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Method returns fabric method for action processing |
|
58
|
|
|
* |
|
59
|
|
|
* @param CommonApplication $app |
|
60
|
|
|
* application |
|
61
|
|
|
* @param string $key |
|
62
|
|
|
* config key name |
|
63
|
|
|
* @param mixed $value |
|
64
|
|
|
* config key value |
|
65
|
|
|
* @return callable|NULL callback |
|
66
|
|
|
*/ |
|
67
|
|
|
public static function getActionBuilderMethod(CommonApplication $app, string $key, $value): ?callable |
|
68
|
|
|
{ |
|
69
|
|
|
if ($key === 'override') { |
|
70
|
|
|
return ActionBuilder::ignoreKey(); |
|
71
|
|
|
} elseif ($key === 'layout') { |
|
72
|
|
|
return ActionBuilder::resetLayout($app->getTemplate(), $value); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return null; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Constructing view |
|
80
|
|
|
* |
|
81
|
|
|
* @param CommonApplication $app |
|
82
|
|
|
* application |
|
83
|
|
|
* @param array $result |
|
84
|
|
|
* compiled result |
|
85
|
|
|
* @param string $key |
|
86
|
|
|
* config key |
|
87
|
|
|
* @param mixed $value |
|
88
|
|
|
* config value |
|
89
|
|
|
* @param array $views |
|
90
|
|
|
* list of views |
|
91
|
|
|
*/ |
|
92
|
|
|
public static function constructOtherView(CommonApplication $app, array &$result, string $key, $value, array &$views): void |
|
93
|
|
|
{ |
|
94
|
|
|
// any other view |
|
95
|
|
|
if (isset($value['name'])) { |
|
96
|
|
|
$views[$key] = new $value['class']($app->getTemplate(), $value['name']); |
|
97
|
|
|
} else { |
|
98
|
|
|
$views[$key] = new $value['class']($app->getTemplate()); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
foreach ($value as $configKey => $configValue) { |
|
102
|
|
|
if (! in_array($configKey, [ |
|
103
|
|
|
'class', |
|
104
|
|
|
'name', |
|
105
|
|
|
'placeholder' |
|
106
|
|
|
])) { |
|
107
|
|
|
$views[$key]->setViewParameter($configKey, $configValue, true); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$result[$value['placeholder']] = $views[$key]; |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
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