p43N
This commit is contained in:
@@ -163,10 +163,14 @@ final class LanguageCleanupConfig
|
||||
private function resolveGroupedTerms(string $profileName, string $profileKey, string $rootKey): array
|
||||
{
|
||||
$profile = $this->requiredCleanupProfile($profileName);
|
||||
$groupNames = $this->stringListFromValue(
|
||||
$this->profileValue($profile, $profileKey),
|
||||
sprintf('cleanup_profiles.%s.%s', $profileName, $profileKey),
|
||||
false
|
||||
$groupNames = $this->resolveProfileGroupSetTerms($profileName, $profile, $profileKey);
|
||||
$groupNames = $this->mergeUnique(
|
||||
$groupNames,
|
||||
$this->stringListFromValue(
|
||||
$this->profileValue($profile, $profileKey),
|
||||
sprintf('cleanup_profiles.%s.%s', $profileName, $profileKey),
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
if ($groupNames === []) {
|
||||
@@ -193,6 +197,66 @@ final class LanguageCleanupConfig
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $profile
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolveProfileGroupSetTerms(string $profileName, array $profile, string $profileKey): array
|
||||
{
|
||||
$profileSetKey = $this->profileGroupSetKey($profileKey);
|
||||
$setNames = $this->stringListFromValue(
|
||||
$this->profileValue($profile, $profileSetKey),
|
||||
sprintf('cleanup_profiles.%s.%s', $profileName, $profileSetKey),
|
||||
false
|
||||
);
|
||||
|
||||
if ($setNames === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rootSetKey = $this->rootGroupSetKey($profileKey);
|
||||
$sets = $this->requiredMap($rootSetKey);
|
||||
$out = [];
|
||||
|
||||
foreach ($setNames as $setName) {
|
||||
if (!array_key_exists($setName, $sets)) {
|
||||
throw $this->invalid(
|
||||
sprintf('cleanup_profiles.%s.%s', $profileName, $profileSetKey),
|
||||
sprintf('references unknown group set "%s"', $setName)
|
||||
);
|
||||
}
|
||||
|
||||
$out = $this->mergeUnique(
|
||||
$out,
|
||||
$this->stringListFromValue($sets[$setName], sprintf('%s.%s', $rootSetKey, $setName), true)
|
||||
);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
private function profileGroupSetKey(string $profileKey): string
|
||||
{
|
||||
if ($profileKey === 'stopword_groups') {
|
||||
return 'stopword_group_sets';
|
||||
}
|
||||
|
||||
if ($profileKey === 'phrase_groups') {
|
||||
return 'phrase_group_sets';
|
||||
}
|
||||
|
||||
if ($profileKey === 'meta_term_groups') {
|
||||
return 'meta_term_group_sets';
|
||||
}
|
||||
|
||||
return sprintf('%s_sets', $profileKey);
|
||||
}
|
||||
|
||||
private function rootGroupSetKey(string $profileKey): string
|
||||
{
|
||||
return $this->profileGroupSetKey($profileKey);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function requiredCleanupProfile(string $profileName): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user