feat: PresetComposer – Preset aus Kurz-/Vollform, Modul und Gruppen-Presets
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
bb4d9b3baf
commit
cc20100cbc
@@ -7,6 +7,7 @@ namespace LIT\MCP\Integrations\Divi\Design;
|
||||
use ET\Builder\Framework\UserRole\UserRole;
|
||||
use ET\Builder\Packages\Conversion\Conversion;
|
||||
use ET\Builder\Packages\GlobalData\GlobalPreset;
|
||||
use ET\Builder\Packages\ModuleLibrary\ModuleRegistration;
|
||||
use LIT\MCP\Integrations\Divi\Release\Call;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviAdapter;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviLocked;
|
||||
@@ -51,6 +52,8 @@ class DesignSystemWriter implements DiviAdapter
|
||||
new Call(GlobalPreset::class . '::save_data', 1),
|
||||
new Call(Conversion::class . '::get_preset_attrs_mapping', 1),
|
||||
new Call(Conversion::class . '::get_preset_attrs', 3),
|
||||
new Call(GlobalPreset::class . '::get_group_preset_default_attr', 1),
|
||||
new Call(ModuleRegistration::class . '::get_module_settings', 1),
|
||||
new Call(UserRole::class . '::can_current_user_use_visual_builder', 0),
|
||||
],
|
||||
mirrors: [
|
||||
@@ -113,6 +116,33 @@ class DesignSystemWriter implements DiviAdapter
|
||||
return is_array($saved) ? $saved : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* The option groups of $moduleName that take group presets: attribute path (groupId) => group name, e.g.
|
||||
* "module.decoration.spacing" => "divi/spacing" (formats §3). [] without Divi or for an unknown module.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function groupsOf(string $moduleName): array
|
||||
{
|
||||
if (! class_exists(ModuleRegistration::class)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$settings = ModuleRegistration::get_module_settings($moduleName);
|
||||
if ($settings === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$groups = [];
|
||||
foreach (GlobalPreset::get_group_preset_default_attr($settings) as $groupId => $group) {
|
||||
if (is_array($group) && is_string($group['groupName'] ?? null)) {
|
||||
$groups[(string) $groupId] = $group['groupName'];
|
||||
}
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* The parts of $attrs a preset of $moduleName carries (Divi's preset attribute mapping): all, style
|
||||
* (styleAttrs) and render (renderAttrs: html + script).
|
||||
|
||||
Reference in New Issue
Block a user