refactor: AbilityRegistrar nimmt AbilityGuard-Liste und ToolRefusal statt DiviToolGate/DiviLocked; DiviToolGate implementiert AbilityGuard, DiviLocked ToolRefusal; Test mit Fake-Guard und Fake-Refusal ohne Divi
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
a7a9c09de8
commit
abeb4b0eed
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\Divi\Release;
|
||||
|
||||
use LIT\MCP\Abilities\ToolRefusal;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
@@ -11,7 +12,7 @@ use WP_Error;
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/** A write refused because the installed Divi is not released (spec §5.5); AbilityRegistrar returns toError(). */
|
||||
final class DiviLocked extends RuntimeException
|
||||
final class DiviLocked extends RuntimeException implements ToolRefusal
|
||||
{
|
||||
public function __construct(public readonly ReleaseStatus $status)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace LIT\MCP\Integrations\Divi\Release;
|
||||
|
||||
use Closure;
|
||||
use LIT\MCP\Abilities\Ability;
|
||||
use LIT\MCP\Abilities\AbilityGuard;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\Divi\Library\LibraryAccess;
|
||||
use LIT\MCP\Integrations\Divi\ThemeBuilder\ThemeBuilderAccess;
|
||||
@@ -17,9 +18,9 @@ defined('ABSPATH') || exit;
|
||||
* The central release lock of the Divi tools (spec §5.5): a writing tool of the groups Divi, Divi-Bibliothek or Divi
|
||||
* Theme Builder is refused before it runs while Divi is not released (logged with result "refused"); a reading tool
|
||||
* runs and gets the notice in warnings. Other tools that reach Divi (lit/content-create with divi) meet the adapter
|
||||
* lock (ReleaseGate::assertWritable()).
|
||||
* lock (ReleaseGate::assertWritable()). The AbilityRegistrar receives it as an AbilityGuard from Plugin.
|
||||
*/
|
||||
final class DiviToolGate
|
||||
final class DiviToolGate implements AbilityGuard
|
||||
{
|
||||
public const GROUPS = ['divi', LibraryAccess::GROUP, ThemeBuilderAccess::GROUP];
|
||||
|
||||
@@ -39,7 +40,7 @@ final class DiviToolGate
|
||||
return in_array(($this->groups)()[$ability->name()] ?? '', self::GROUPS, true);
|
||||
}
|
||||
|
||||
public function refusal(Ability $ability): ?WP_Error
|
||||
public function refusal(Ability $ability, array $input): ?WP_Error
|
||||
{
|
||||
if (! $this->covers($ability) || self::readsOnly($ability)) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user