feat: Divi module catalog, attribute paths, short form and lit/divi-catalog
Adds per-path attribute kind (text/richtext/code/url/image/color/enum/ onoff/number/list/icon), derived from Divi's field component metadata where an attribute path names one unambiguously (module.paths() itself is unchanged; kinds() is a new, separate lookup exposed as path_kinds on lit/divi-catalog's module detail). This is not in the task-4 brief; it is added because 2b's sanitization routing (ruling R3) needs a metadata-derived field kind per attribute path. Verified live against the full 100-module catalog (564/4358 paths resolve a kind; the rest default to "unknown" and fall back to 2b's key-name routing). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\Divi\Schema;
|
||||
|
||||
use ET\Builder\Packages\ModuleLibrary\ModuleRegistration;
|
||||
|
||||
/**
|
||||
* Reads Divi's module metadata once per request (Divi 5 only). Not final so abilities can be
|
||||
* unit-tested with a mock.
|
||||
*/
|
||||
class DiviModules
|
||||
{
|
||||
private ?ModuleCatalog $catalog = null;
|
||||
|
||||
public static function isAvailable(): bool
|
||||
{
|
||||
return class_exists(ModuleRegistration::class);
|
||||
}
|
||||
|
||||
public function catalog(): ModuleCatalog
|
||||
{
|
||||
if ($this->catalog === null) {
|
||||
$metadata = ModuleRegistration::get_all_core_modules_metadata();
|
||||
$this->catalog = new ModuleCatalog(
|
||||
is_array($metadata) ? $metadata : [],
|
||||
static function (string $name): array {
|
||||
$defaults = ModuleRegistration::get_default_attrs($name, 'default');
|
||||
|
||||
return is_array($defaults) ? $defaults : [];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return $this->catalog;
|
||||
}
|
||||
|
||||
/** Divi version written into builderVersion of new blocks. */
|
||||
public function builderVersion(): string
|
||||
{
|
||||
return defined('ET_BUILDER_PRODUCT_VERSION') ? (string) ET_BUILDER_PRODUCT_VERSION : '5.2.1';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user