Files
roi-theme/Admin/CtaPost/Infrastructure/FieldMapping/CtaPostFieldMapper.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

70 lines
3.7 KiB
PHP

<?php
declare(strict_types=1);
namespace ROITheme\Admin\CtaPost\Infrastructure\FieldMapping;
use ROITheme\Admin\Shared\Domain\Contracts\FieldMapperInterface;
/**
* Field Mapper para CTA Post
*
* RESPONSABILIDAD:
* - Mapear field IDs del formulario a atributos de BD
* - Solo conoce sus propios campos (modularidad)
*/
final class CtaPostFieldMapper implements FieldMapperInterface
{
public function getComponentName(): string
{
return 'cta-post';
}
public function getFieldMapping(): array
{
return [
// Visibility
'ctaPostEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
'ctaPostShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
'ctaPostShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],
'ctaPostShowOnPages' => ['group' => 'visibility', 'attribute' => 'show_on_pages'],
// Content
'ctaPostTitle' => ['group' => 'content', 'attribute' => 'title'],
'ctaPostDescription' => ['group' => 'content', 'attribute' => 'description'],
'ctaPostButtonText' => ['group' => 'content', 'attribute' => 'button_text'],
'ctaPostButtonUrl' => ['group' => 'content', 'attribute' => 'button_url'],
'ctaPostButtonIcon' => ['group' => 'content', 'attribute' => 'button_icon'],
// Typography
'ctaPostTitleFontSize' => ['group' => 'typography', 'attribute' => 'title_font_size'],
'ctaPostTitleFontWeight' => ['group' => 'typography', 'attribute' => 'title_font_weight'],
'ctaPostDescriptionFontSize' => ['group' => 'typography', 'attribute' => 'description_font_size'],
'ctaPostButtonFontSize' => ['group' => 'typography', 'attribute' => 'button_font_size'],
// Colors
'ctaPostGradientStart' => ['group' => 'colors', 'attribute' => 'gradient_start'],
'ctaPostGradientEnd' => ['group' => 'colors', 'attribute' => 'gradient_end'],
'ctaPostTitleColor' => ['group' => 'colors', 'attribute' => 'title_color'],
'ctaPostDescriptionColor' => ['group' => 'colors', 'attribute' => 'description_color'],
'ctaPostButtonBgColor' => ['group' => 'colors', 'attribute' => 'button_bg_color'],
'ctaPostButtonTextColor' => ['group' => 'colors', 'attribute' => 'button_text_color'],
'ctaPostButtonHoverBg' => ['group' => 'colors', 'attribute' => 'button_hover_bg'],
// Spacing
'ctaPostContainerMarginTop' => ['group' => 'spacing', 'attribute' => 'container_margin_top'],
'ctaPostContainerMarginBottom' => ['group' => 'spacing', 'attribute' => 'container_margin_bottom'],
'ctaPostContainerPadding' => ['group' => 'spacing', 'attribute' => 'container_padding'],
'ctaPostTitleMarginBottom' => ['group' => 'spacing', 'attribute' => 'title_margin_bottom'],
'ctaPostButtonIconMargin' => ['group' => 'spacing', 'attribute' => 'button_icon_margin'],
// Visual Effects
'ctaPostBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'border_radius'],
'ctaPostGradientAngle' => ['group' => 'visual_effects', 'attribute' => 'gradient_angle'],
'ctaPostButtonBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'button_border_radius'],
'ctaPostButtonPadding' => ['group' => 'visual_effects', 'attribute' => 'button_padding'],
'ctaPostTransitionDuration' => ['group' => 'visual_effects', 'attribute' => 'transition_duration'],
'ctaPostBoxShadow' => ['group' => 'visual_effects', 'attribute' => 'box_shadow'],
];
}
}