feat: admin check steps with throwaway write test and reports
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\Divi\Schema;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* The curated short form against a module catalog (spec §6.2 step 2): every module exists, every field path is a
|
||||
* known attribute path, every item type is an allowed child. Pure PHP; the admin check passes Divi's live catalog.
|
||||
*/
|
||||
final class ShortformCheck
|
||||
{
|
||||
/** @return list<string> German problems; [] = the short form matches. */
|
||||
public static function problems(ModuleCatalog $catalog): array
|
||||
{
|
||||
$problems = [];
|
||||
foreach (ShortformMap::types() as $type) {
|
||||
$name = ModuleCatalog::normalize($type);
|
||||
if (! $catalog->has($name)) {
|
||||
$problems[] = $name . ': unbekanntes Modul';
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (ShortformMap::fields($type) as $field => $spec) {
|
||||
if (! $catalog->isKnownPath($name, (string) $spec['path'])) {
|
||||
$problems[] = sprintf(
|
||||
'%s.%s: unbekannter Pfad %s (ähnlich: %s)',
|
||||
$type,
|
||||
$field,
|
||||
$spec['path'],
|
||||
implode(', ', $catalog->suggestions($name, (string) $spec['path']))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$child = ShortformMap::childType($type);
|
||||
if ($child !== null && ! in_array(ModuleCatalog::normalize($child), $catalog->childrenOf($name), true)) {
|
||||
$problems[] = sprintf(
|
||||
'%s: %s ist kein erlaubtes Kind (%s)',
|
||||
$type,
|
||||
$child,
|
||||
implode(', ', $catalog->childrenOf($name))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $problems;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user