|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Shopware\Core\System\SystemConfig\Event; |
|
4
|
|
|
|
|
5
|
|
|
use Shopware\Core\Framework\App\AppEntity; |
|
|
|
|
|
|
6
|
|
|
use Shopware\Core\Framework\Log\Package; |
|
7
|
|
|
use Shopware\Core\Framework\Webhook\AclPrivilegeCollection; |
|
8
|
|
|
use Shopware\Core\Framework\Webhook\Hookable; |
|
9
|
|
|
|
|
10
|
|
|
#[Package('core')] |
|
11
|
|
|
class SystemConfigChangedHook implements Hookable |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @param array<string, mixed> $values |
|
15
|
|
|
* @param array<string, string> $appMapping |
|
16
|
|
|
*/ |
|
17
|
|
|
public function __construct( |
|
18
|
|
|
private readonly array $values, |
|
19
|
|
|
private readonly array $appMapping |
|
20
|
|
|
) { |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function getName(): string |
|
24
|
|
|
{ |
|
25
|
|
|
return 'app.config.changed'; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @return array{changes: array<string>} |
|
30
|
|
|
*/ |
|
31
|
|
|
public function getWebhookPayload(?AppEntity $app = null): array |
|
32
|
|
|
{ |
|
33
|
|
|
if ($app === null) { |
|
34
|
|
|
return [ |
|
35
|
|
|
'changes' => array_keys($this->values), |
|
36
|
|
|
]; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
$values = []; |
|
40
|
|
|
|
|
41
|
|
|
foreach ($this->values as $key => $value) { |
|
42
|
|
|
if (str_starts_with($key, $app->getName() . '.')) { |
|
43
|
|
|
$values[] = $key; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return [ |
|
48
|
|
|
'changes' => $values, |
|
49
|
|
|
]; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function isAllowed(string $appId, AclPrivilegeCollection $permissions): bool |
|
53
|
|
|
{ |
|
54
|
|
|
// Needs basic system_config.read permission |
|
55
|
|
|
if (!$permissions->isAllowed('system_config', 'read')) { |
|
56
|
|
|
return false; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$appName = $this->appMapping[$appId] ?? null; |
|
60
|
|
|
|
|
61
|
|
|
// When app doesn't exist |
|
62
|
|
|
if ($appName === null) { |
|
63
|
|
|
return false; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
foreach ($this->values as $k => $v) { |
|
67
|
|
|
if (str_starts_with($k, $appName . '.')) { |
|
68
|
|
|
return true; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return false; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
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