feat: Divi release status, store, resolver and gate
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\Divi\Release;
|
||||
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
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
|
||||
{
|
||||
public function __construct(public readonly ReleaseStatus $status)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'%s is %s for LIT MCP – write refused',
|
||||
$status->versionLabel(),
|
||||
$status->state->value
|
||||
));
|
||||
}
|
||||
|
||||
public function toError(): WP_Error
|
||||
{
|
||||
return $this->status->refusal();
|
||||
}
|
||||
|
||||
/** The lock anywhere in $e's chain of previous exceptions (callers wrap failures in WriteFailed). */
|
||||
public static function in(Throwable $e): ?self
|
||||
{
|
||||
for ($cause = $e; $cause !== null; $cause = $cause->getPrevious()) {
|
||||
if ($cause instanceof self) {
|
||||
return $cause;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user