fix: PresetComposer liest nur den von der Ability bereinigten Namen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3d760113ec
commit
d5fd1642b8
@@ -222,7 +222,7 @@ final class DiviPresetsSetAbility implements Ability
|
||||
/**
|
||||
* Scope, preset to change and source node of one item; null after noting the problem in $errors.
|
||||
*
|
||||
* @param array<array-key, mixed> $item Names are replaced by their cleaned form.
|
||||
* @param array<array-key, mixed> $item name/rename become the cleaned "name" PresetComposer reads (M-5).
|
||||
* @param array<string, string> $errors
|
||||
* @return array{PresetScope, array<string, mixed>|null, Block|null}|null
|
||||
*/
|
||||
@@ -274,7 +274,8 @@ final class DiviPresetsSetAbility implements Ability
|
||||
|
||||
return null;
|
||||
}
|
||||
$item[$key] = $name;
|
||||
unset($item['rename']);
|
||||
$item['name'] = $name;
|
||||
$taken = array_diff($book->idsNamed($scope, $name), [(string) ($existing['id'] ?? '')]);
|
||||
if ($taken !== []) {
|
||||
$errors[$field . '.' . $key] = sprintf(
|
||||
|
||||
@@ -43,7 +43,8 @@ final class PresetComposer
|
||||
|
||||
/**
|
||||
* @param array<string, mixed>|null $existing The preset to change, null for a new one.
|
||||
* @param array<string, mixed> $input One item of lit/divi-presets-set.
|
||||
* @param array<string, mixed> $input One item of lit/divi-presets-set; "name" is the resolved, cleaned
|
||||
* name (new or renamed), "rename" is not read.
|
||||
* @return array{item: array<string, mixed>, errors: array<string, string>, invalid_paths: list<string>}
|
||||
*/
|
||||
public function compose(
|
||||
@@ -238,16 +239,16 @@ final class PresetComposer
|
||||
}
|
||||
|
||||
/**
|
||||
* The name the ability resolved and cleaned ("name", also for a rename), else the existing preset's name.
|
||||
*
|
||||
* @param array<string, mixed>|null $existing
|
||||
* @param array<string, mixed> $input
|
||||
* @param array<string, string> $errors
|
||||
*/
|
||||
private function nameOf(?array $existing, array $input, string $field, array &$errors): string
|
||||
{
|
||||
foreach (['rename', 'name'] as $key) {
|
||||
if (is_string($input[$key] ?? null) && trim($input[$key]) !== '') {
|
||||
return trim($input[$key]);
|
||||
}
|
||||
if (is_string($input['name'] ?? null) && $input['name'] !== '') {
|
||||
return $input['name'];
|
||||
}
|
||||
if (is_string($existing['name'] ?? null)) {
|
||||
return $existing['name'];
|
||||
|
||||
Reference in New Issue
Block a user