Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
77 lines
1.9 KiB
PHP
77 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Integrations\WordPress\Content;
|
|
|
|
use LIT\MCP\Abilities\Ability;
|
|
use LIT\MCP\Integrations\WordPress\PostGuard;
|
|
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
|
use WP_Error;
|
|
|
|
final class ContentGetAbility implements Ability
|
|
{
|
|
public function __construct(private ContentSchema $schema, private PostPresenter $presenter)
|
|
{
|
|
}
|
|
|
|
public function name(): string
|
|
{
|
|
return 'lit/content-get';
|
|
}
|
|
|
|
public function label(): string
|
|
{
|
|
return 'Inhalt lesen';
|
|
}
|
|
|
|
public function description(): string
|
|
{
|
|
return 'Liest einen Eintrag vollständig: Kerndaten, Inhalt, Begriffe, alle Felder (Pods/Meta), '
|
|
. 'Beitragsbild, rev (für lit-content-update). Bei Divi-Inhalten wird content nicht ausgegeben; '
|
|
. 'hints verweist dann auf lit-divi-outline.';
|
|
}
|
|
|
|
public function inputSchema(): array
|
|
{
|
|
return [
|
|
'type' => 'object',
|
|
'properties' => ['post_id' => ['type' => 'integer', 'minimum' => 1]],
|
|
'required' => ['post_id'],
|
|
'additionalProperties' => false,
|
|
];
|
|
}
|
|
|
|
public function outputSchema(): ?array
|
|
{
|
|
return PostPresenter::fullSchema();
|
|
}
|
|
|
|
public function annotations(): array
|
|
{
|
|
return ['readonly' => true, 'destructive' => false, 'idempotent' => true];
|
|
}
|
|
|
|
public function isDirect(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function permission(array $input): bool|WP_Error
|
|
{
|
|
$post = PostGuard::editable($input['post_id'] ?? null, $this->schema);
|
|
|
|
return $post instanceof WP_Error ? $post : true;
|
|
}
|
|
|
|
public function execute(array $input): mixed
|
|
{
|
|
$post = PostGuard::editable($input['post_id'] ?? null, $this->schema);
|
|
if ($post instanceof WP_Error) {
|
|
return $post;
|
|
}
|
|
|
|
return $this->presenter->full($post);
|
|
}
|
|
}
|