feat: lit/menu-create returns the new menu's menu_rev (trial)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -8,6 +8,7 @@ use LIT\MCP\Abilities\Ability;
|
||||
use LIT\MCP\Abilities\Annotations;
|
||||
use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Abilities\FollowUp;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use WP_Error;
|
||||
@@ -35,7 +36,7 @@ final class MenuCreateAbility implements Ability
|
||||
public function description(): string
|
||||
{
|
||||
return 'Legt ein leeres Menü an und weist es optional einer Theme-Position zu. Einträge danach mit '
|
||||
. 'lit/menu-set-items setzen.';
|
||||
. 'lit/menu-set-items setzen; die Antwort enthält dafür menu_id und menu_rev.';
|
||||
}
|
||||
|
||||
public function inputSchema(): array
|
||||
@@ -53,7 +54,13 @@ final class MenuCreateAbility implements Ability
|
||||
|
||||
public function outputSchema(): ?array
|
||||
{
|
||||
return ToolResult::schema(['menu_id' => ['type' => 'integer']], ['menu_id']);
|
||||
return ToolResult::schema(
|
||||
[
|
||||
'menu_id' => ['type' => 'integer'],
|
||||
'menu_rev' => ['type' => 'string', 'description' => 'Stand des Menüs für lit/menu-set-items.'],
|
||||
],
|
||||
['menu_id', 'menu_rev']
|
||||
);
|
||||
}
|
||||
|
||||
public function annotations(): array
|
||||
@@ -98,6 +105,8 @@ final class MenuCreateAbility implements Ability
|
||||
MenuLocations::assign($location, $menuId);
|
||||
}
|
||||
|
||||
$items = wp_get_nav_menu_items($menuId);
|
||||
|
||||
// The menu is saved – a change log failure from here on is logged and reported as a warning only.
|
||||
$warnings = [];
|
||||
$summary = sprintf('Menü "%s" angelegt', $name)
|
||||
@@ -114,6 +123,7 @@ final class MenuCreateAbility implements Ability
|
||||
->logId(is_int($logId) ? $logId : null)
|
||||
->warnings($warnings)
|
||||
->with('menu_id', $menuId)
|
||||
->with('menu_rev', Rev::ofMenu(is_array($items) ? $items : []))
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user