hook suppress
This commit is contained in:
@@ -171,8 +171,8 @@ class HookManager
|
||||
|
||||
/**
|
||||
* @param string $hookDir
|
||||
* @param array<string,array<string,mixed>> $hookData
|
||||
* @return array<string,array<string,mixed>>
|
||||
* @param array<string, array<string, mixed>> $hookData
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
private function readHookData(string $hookDir, array $hookData = []): array
|
||||
{
|
||||
@@ -180,7 +180,7 @@ class HookManager
|
||||
return $hookData;
|
||||
}
|
||||
|
||||
/** @var array<string,string[]> $fileList */
|
||||
/** @var array<string, string[]> $fileList */
|
||||
$fileList = $this->fileManager->getFileList($hookDir, 1, '\.php$', true);
|
||||
|
||||
foreach ($fileList as $scopeName => $hookFiles) {
|
||||
@@ -197,7 +197,7 @@ class HookManager
|
||||
|
||||
/** @var string[] $hookMethods */
|
||||
$hookMethods = array_filter($hookMethods, function ($item) {
|
||||
if (strpos($item, 'set') === 0) {
|
||||
if (str_starts_with($item, 'set')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -211,6 +211,10 @@ class HookManager
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->hookClassIsSuppressed($className)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hookData[$normalizedScopeName][$hookType][] = [
|
||||
'className' => $className,
|
||||
'order' => $className::$order ?? self::DEFAULT_ORDER,
|
||||
@@ -222,6 +226,16 @@ class HookManager
|
||||
return $hookData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string $className
|
||||
*/
|
||||
private function hookClassIsSuppressed(string $className): bool
|
||||
{
|
||||
$suppressList = $this->metadata->get(['app', 'hook', 'suppressClassNameList']) ?? [];
|
||||
|
||||
return in_array($className, $suppressList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort hooks by the order parameter.
|
||||
*
|
||||
|
||||
@@ -76,6 +76,7 @@ class Metadata
|
||||
['app', 'fieldProcessing', 'readLoaderClassNameList'],
|
||||
['app', 'fieldProcessing', 'listLoaderClassNameList'],
|
||||
['app', 'fieldProcessing', 'saverClassNameList'],
|
||||
['app', 'hook', 'suppressClassNameList'],
|
||||
['recordDefs', self::ANY_KEY, 'readLoaderClassNameList'],
|
||||
['recordDefs', self::ANY_KEY, 'listLoaderClassNameList'],
|
||||
['recordDefs', self::ANY_KEY, 'saverClassNameList'],
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"suppressClassNameList": []
|
||||
}
|
||||
@@ -28,6 +28,7 @@
|
||||
["app", "smsProviders", "__ANY__", "senderClassName"],
|
||||
["app", "orm"],
|
||||
["app", "linkManager"],
|
||||
["app", "hook"],
|
||||
["selectDefs"],
|
||||
["recordDefs"],
|
||||
["pdfDefs"],
|
||||
|
||||
Reference in New Issue
Block a user