Files
roi-theme/Admin/TableOfContents/Infrastructure/FieldMapping/TableOfContentsFieldMapper.php
FrankZamora 4f11c2c312 refactor(admin): Migrate AdminAjaxHandler to Clean Architecture
- Move AdminAjaxHandler to Admin/Shared/Infrastructure/Api/Wordpress/
- Create FieldMapperInterface for decentralized field mapping
- Create FieldMapperRegistry for module discovery
- Create FieldMapperProvider for auto-registration of 12 mappers
- Add FieldMappers for all components:
  - ContactFormFieldMapper (46 fields)
  - CtaBoxSidebarFieldMapper (32 fields)
  - CtaLetsTalkFieldMapper
  - CtaPostFieldMapper
  - FeaturedImageFieldMapper (15 fields)
  - FooterFieldMapper (31 fields)
  - HeroFieldMapper
  - NavbarFieldMapper
  - RelatedPostFieldMapper (34 fields)
  - SocialShareFieldMapper
  - TableOfContentsFieldMapper
  - TopNotificationBarFieldMapper (17 fields)
- Update functions.php bootstrap with FieldMapperProvider
- AdminAjaxHandler reduced from ~700 to 145 lines
- Follows SRP, OCP, DIP principles

BACKUP BEFORE: Removing CTA A/B Testing legacy system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:18:55 -06:00

86 lines
5.0 KiB
PHP

<?php
declare(strict_types=1);
namespace ROITheme\Admin\TableOfContents\Infrastructure\FieldMapping;
use ROITheme\Admin\Shared\Domain\Contracts\FieldMapperInterface;
/**
* Field Mapper para Table of Contents
*
* RESPONSABILIDAD:
* - Mapear field IDs del formulario a atributos de BD
* - Solo conoce sus propios campos (modularidad)
*/
final class TableOfContentsFieldMapper implements FieldMapperInterface
{
public function getComponentName(): string
{
return 'table-of-contents';
}
public function getFieldMapping(): array
{
return [
// Visibility
'tocEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
'tocShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
'tocShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],
'tocShowOnPages' => ['group' => 'visibility', 'attribute' => 'show_on_pages'],
// Content
'tocTitle' => ['group' => 'content', 'attribute' => 'title'],
'tocAutoGenerate' => ['group' => 'content', 'attribute' => 'auto_generate'],
'tocHeadingLevels' => ['group' => 'content', 'attribute' => 'heading_levels'],
'tocSmoothScroll' => ['group' => 'content', 'attribute' => 'smooth_scroll'],
// Typography
'tocTitleFontSize' => ['group' => 'typography', 'attribute' => 'title_font_size'],
'tocTitleFontWeight' => ['group' => 'typography', 'attribute' => 'title_font_weight'],
'tocLinkFontSize' => ['group' => 'typography', 'attribute' => 'link_font_size'],
'tocLinkLineHeight' => ['group' => 'typography', 'attribute' => 'link_line_height'],
'tocLevelThreeFontSize' => ['group' => 'typography', 'attribute' => 'level_three_font_size'],
'tocLevelFourFontSize' => ['group' => 'typography', 'attribute' => 'level_four_font_size'],
// Colors
'tocBackgroundColor' => ['group' => 'colors', 'attribute' => 'background_color'],
'tocBorderColor' => ['group' => 'colors', 'attribute' => 'border_color'],
'tocTitleColor' => ['group' => 'colors', 'attribute' => 'title_color'],
'tocTitleBorderColor' => ['group' => 'colors', 'attribute' => 'title_border_color'],
'tocLinkColor' => ['group' => 'colors', 'attribute' => 'link_color'],
'tocLinkHoverColor' => ['group' => 'colors', 'attribute' => 'link_hover_color'],
'tocLinkHoverBackground' => ['group' => 'colors', 'attribute' => 'link_hover_background'],
'tocActiveBorderColor' => ['group' => 'colors', 'attribute' => 'active_border_color'],
'tocActiveBackgroundColor' => ['group' => 'colors', 'attribute' => 'active_background_color'],
'tocActiveTextColor' => ['group' => 'colors', 'attribute' => 'active_text_color'],
'tocScrollbarTrackColor' => ['group' => 'colors', 'attribute' => 'scrollbar_track_color'],
'tocScrollbarThumbColor' => ['group' => 'colors', 'attribute' => 'scrollbar_thumb_color'],
// Spacing
'tocContainerPadding' => ['group' => 'spacing', 'attribute' => 'container_padding'],
'tocMarginBottom' => ['group' => 'spacing', 'attribute' => 'margin_bottom'],
'tocTitlePaddingBottom' => ['group' => 'spacing', 'attribute' => 'title_padding_bottom'],
'tocTitleMarginBottom' => ['group' => 'spacing', 'attribute' => 'title_margin_bottom'],
'tocItemMarginBottom' => ['group' => 'spacing', 'attribute' => 'item_margin_bottom'],
'tocLinkPadding' => ['group' => 'spacing', 'attribute' => 'link_padding'],
'tocLevelThreePaddingLeft' => ['group' => 'spacing', 'attribute' => 'level_three_padding_left'],
'tocLevelFourPaddingLeft' => ['group' => 'spacing', 'attribute' => 'level_four_padding_left'],
'tocScrollbarWidth' => ['group' => 'spacing', 'attribute' => 'scrollbar_width'],
// Visual Effects
'tocBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'border_radius'],
'tocBoxShadow' => ['group' => 'visual_effects', 'attribute' => 'box_shadow'],
'tocBorderWidth' => ['group' => 'visual_effects', 'attribute' => 'border_width'],
'tocLinkBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'link_border_radius'],
'tocActiveBorderLeftWidth' => ['group' => 'visual_effects', 'attribute' => 'active_border_left_width'],
'tocTransitionDuration' => ['group' => 'visual_effects', 'attribute' => 'transition_duration'],
'tocScrollbarBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'scrollbar_border_radius'],
// Behavior
'tocIsSticky' => ['group' => 'behavior', 'attribute' => 'is_sticky'],
'tocScrollOffset' => ['group' => 'behavior', 'attribute' => 'scroll_offset'],
'tocMaxHeight' => ['group' => 'behavior', 'attribute' => 'max_height'],
];
}
}