feat: Divi-Adapter sperren je Fähigkeit – ReleaseGate::feature/assertFeature(s), DiviLocked und Ablehnung nennen die betroffenen Fähigkeiten (D6), DiviSaver prüft Seiten schreiben und die Fähigkeit des Speicherbereichs (D5), DesignArea::feature; Test-Standard alle Fähigkeiten freigegeben
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c4efeb3ba4
commit
e387d8d29e
@@ -61,11 +61,11 @@ final class DiviPages implements DiviAdapter
|
||||
|
||||
/**
|
||||
* @throws RuntimeException When a flag does not read back as set.
|
||||
* @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written.
|
||||
* @throws DiviLocked When page-write is not released (spec §5.5) – before anything is written.
|
||||
*/
|
||||
public static function setFlags(int $postId): void
|
||||
{
|
||||
ReleaseGate::assertWritable($postId);
|
||||
ReleaseGate::assertFeature(DiviFeature::PageWrite, $postId);
|
||||
foreach (self::FLAGS as $key => $value) {
|
||||
update_post_meta($postId, $key, $value);
|
||||
}
|
||||
|
||||
@@ -71,12 +71,12 @@ class DiviSaver
|
||||
/**
|
||||
* @return array{revision_id: ?int, warnings: list<string>}
|
||||
* @throws WriteFailed
|
||||
* @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written.
|
||||
* @throws DiviLocked When a feature of $scope is not released (spec §5.5, D5) – before anything is written.
|
||||
*/
|
||||
public function save(WP_Post $post, string $content, SaveScope $scope = SaveScope::Page): array
|
||||
{
|
||||
$postId = (int) $post->ID;
|
||||
ReleaseGate::assertWritable($postId);
|
||||
ReleaseGate::assertFeatures($scope->features(), $postId);
|
||||
$revisionId = null;
|
||||
|
||||
try {
|
||||
@@ -142,11 +142,11 @@ class DiviSaver
|
||||
*
|
||||
* @return list<string> Warnings (CHANGED_ON_SAVE).
|
||||
* @throws RuntimeException
|
||||
* @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written.
|
||||
* @throws DiviLocked When a feature of $scope is not released (spec §5.5, D5) – before anything is written.
|
||||
*/
|
||||
public function saveNew(int $postId, string $content, SaveScope $scope = SaveScope::Page): array
|
||||
{
|
||||
ReleaseGate::assertWritable($postId);
|
||||
ReleaseGate::assertFeatures($scope->features(), $postId);
|
||||
$refusal = self::refusal($this->writeContent($postId, $content));
|
||||
if ($refusal !== null) {
|
||||
throw new RuntimeException(sprintf('wp_update_post(%d) refused the Divi layout: %s', $postId, $refusal));
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\Divi\Pages;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
// The installed PHPCompatibility sniffs predate enums (PHP 8.1) and read their methods as plain functions.
|
||||
@@ -33,4 +35,14 @@ enum SaveScope
|
||||
{
|
||||
return $this === self::GlobalItem || $this === self::ThemeBuilderLayout;
|
||||
}
|
||||
|
||||
/** @return list<DiviFeature> What a write in this scope needs (D5): page-write and the feature of its area. */
|
||||
public function features(): array
|
||||
{
|
||||
return match ($this) {
|
||||
self::Page => [DiviFeature::PageWrite],
|
||||
self::LibraryItem, self::GlobalItem => [DiviFeature::PageWrite, DiviFeature::LibraryWrite],
|
||||
self::ThemeBuilderLayout => [DiviFeature::PageWrite, DiviFeature::ThemeBuilderWrite],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user